Mercurial > cpython-lru_cache-weakref
diff Python/compile.c @ 58707:76cf60e2d005 legacy-trunk
normalize exceptions passed to the __exit__ method #7853
In Python 2.x, exceptions in finally blocks are not normalized. Since with
statements are implemented using finally blocks, ceval.c had to be tweaked to
distinguish between with finally blocks and normal ones.
A test for the finalization of generators containing with statements was also
added.
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Fri, 05 Feb 2010 02:12:14 +0000 |
| parents | edfed0e32ced |
| children | b879209c202f |
line wrap: on
line diff
--- a/Python/compile.c Fri Feb 05 01:53:27 2010 +0000 +++ b/Python/compile.c Fri Feb 05 02:12:14 2010 +0000 @@ -2927,6 +2927,9 @@ /* SETUP_WITH pushes a finally block. */ compiler_use_next_block(c, block); + /* Note that the block is actually called SETUP_WITH in ceval.c, but + functions the same as SETUP_FINALLY except that exceptions are + normalized. */ if (!compiler_push_fblock(c, FINALLY_TRY, block)) { return 0; }
