File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -1203,35 +1203,41 @@ class CM:
1203
1203
def __aenter__ (self ):
1204
1204
pass
1205
1205
1206
+ body_executed = False
1206
1207
async def foo ():
1207
1208
async with CM ():
1208
- pass
1209
+ body_executed = True
1209
1210
1210
1211
with self .assertRaisesRegex (AttributeError , '__aexit__' ):
1211
1212
run_async (foo ())
1213
+ self .assertFalse (body_executed )
1212
1214
1213
1215
def test_with_3 (self ):
1214
1216
class CM :
1215
1217
def __aexit__ (self ):
1216
1218
pass
1217
1219
1220
+ body_executed = False
1218
1221
async def foo ():
1219
1222
async with CM ():
1220
- pass
1223
+ body_executed = True
1221
1224
1222
1225
with self .assertRaisesRegex (AttributeError , '__aenter__' ):
1223
1226
run_async (foo ())
1227
+ self .assertFalse (body_executed )
1224
1228
1225
1229
def test_with_4 (self ):
1226
1230
class CM :
1227
1231
pass
1228
1232
1233
+ body_executed = False
1229
1234
async def foo ():
1230
1235
async with CM ():
1231
- pass
1236
+ body_executed = True
1232
1237
1233
1238
with self .assertRaisesRegex (AttributeError , '__aenter__' ):
1234
1239
run_async (foo ())
1240
+ self .assertFalse (body_executed )
1235
1241
1236
1242
def test_with_5 (self ):
1237
1243
# While this test doesn't make a lot of sense,
Original file line number Diff line number Diff line change @@ -3154,8 +3154,8 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
3154
3154
}
3155
3155
3156
3156
case TARGET (BEFORE_ASYNC_WITH ): {
3157
- _Py_IDENTIFIER (__aexit__ );
3158
3157
_Py_IDENTIFIER (__aenter__ );
3158
+ _Py_IDENTIFIER (__aexit__ );
3159
3159
PyObject * mgr = TOP ();
3160
3160
PyObject * enter = special_lookup (tstate , mgr , & PyId___aenter__ );
3161
3161
PyObject * res ;
@@ -3189,8 +3189,8 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
3189
3189
}
3190
3190
3191
3191
case TARGET (SETUP_WITH ): {
3192
- _Py_IDENTIFIER (__exit__ );
3193
3192
_Py_IDENTIFIER (__enter__ );
3193
+ _Py_IDENTIFIER (__exit__ );
3194
3194
PyObject * mgr = TOP ();
3195
3195
PyObject * enter = special_lookup (tstate , mgr , & PyId___enter__ );
3196
3196
PyObject * res ;
You can’t perform that action at this time.
0 commit comments