@@ -1155,11 +1155,18 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
|
1155 | 1155 | Py_MakePendingCalls() above. */ |
1156 | 1156 | |
1157 | 1157 | if (_Py_atomic_load_relaxed(&eval_breaker)) { |
1158 | | -if (_Py_OPCODE(*next_instr) == SETUP_FINALLY || |
1159 | | -_Py_OPCODE(*next_instr) == YIELD_FROM) { |
1160 | | -/* Two cases where we skip running signal handlers and other |
| 1158 | +opcode = _Py_OPCODE(*next_instr); |
| 1159 | +if (opcode == SETUP_FINALLY || |
| 1160 | +opcode == SETUP_WITH || |
| 1161 | +opcode == BEFORE_ASYNC_WITH || |
| 1162 | +opcode == YIELD_FROM) { |
| 1163 | +/* Few cases where we skip running signal handlers and other |
1161 | 1164 | pending calls: |
1162 | | - - If we're about to enter the try: of a try/finally (not |
| 1165 | + - If we're about to enter the 'with:'. It will prevent |
| 1166 | + emitting a resource warning in the common idiom |
| 1167 | + 'with open(path) as file:'. |
| 1168 | + - If we're about to enter the 'async with:'. |
| 1169 | + - If we're about to enter the 'try:' of a try/finally (not |
1163 | 1170 | *very* useful, but might help in some cases and it's |
1164 | 1171 | traditional) |
1165 | 1172 | - If we're resuming a chain of nested 'yield from' or |
|