mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
Allow try/except in with block
This commit is contained in:
parent
34ea0a5b1d
commit
5166d39584
8 changed files with 46 additions and 25 deletions
|
|
@ -787,6 +787,26 @@ _PyCompile_TopFBlock(compiler *c)
|
|||
return &c->u->u_fblock[c->u->u_nfblocks - 1];
|
||||
}
|
||||
|
||||
bool
|
||||
_PyCompile_InExceptionHandler(compiler *c)
|
||||
{
|
||||
for (Py_ssize_t i = c->u->u_nfblocks; i < c->u->u_nfblocks; i++) {
|
||||
fblockinfo *block = &c->u->u_fblock[i];
|
||||
switch (block->fb_type) {
|
||||
case COMPILE_FBLOCK_TRY_EXCEPT:
|
||||
case COMPILE_FBLOCK_FINALLY_TRY:
|
||||
case COMPILE_FBLOCK_FINALLY_END:
|
||||
case COMPILE_FBLOCK_EXCEPTION_HANDLER:
|
||||
case COMPILE_FBLOCK_EXCEPTION_GROUP_HANDLER:
|
||||
case COMPILE_FBLOCK_HANDLER_CLEANUP:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
_PyCompile_DeferredAnnotations(compiler *c,
|
||||
PyObject **deferred_annotations,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue