summaryrefslogtreecommitdiff
path: root/Python/compile.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-02-05 02:12:14 +0000
committerBenjamin Peterson <benjamin@python.org>2010-02-05 02:12:14 +0000
commit7ddf99207e672887bf09b1b9dc811a933bfab8a8 (patch)
tree8eb57b12abca704332da6c6c92a702ba9ee4783b /Python/compile.c
parenta90d438e3495c5ba8e718dc03e5075a830fbad4f (diff)
downloadcpython-7ddf99207e672887bf09b1b9dc811a933bfab8a8.tar.gz
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.
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 1e275390c9..4ea2ee9afe 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -2927,6 +2927,9 @@ compiler_with(struct compiler *c, stmt_ty s)
/* 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;
}