diff options
author | Guido van Rossum <guido@python.org> | 2007-01-10 18:51:35 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-01-10 18:51:35 +0000 |
commit | 16be03e4a206c24b00dc1d2d3c740dffbbfc4ac9 (patch) | |
tree | 459a125a265abb16399baeea398ab116b7bf4f9b /Lib/compiler/pycodegen.py | |
parent | b940e113bf90ff71b0ef57414ea2beea9d2a4bc0 (diff) | |
download | cpython-git-16be03e4a206c24b00dc1d2d3c740dffbbfc4ac9.tar.gz |
Some more changes related to the new except syntax and semantics,
by Collin Winter.
Diffstat (limited to 'Lib/compiler/pycodegen.py')
-rw-r--r-- | Lib/compiler/pycodegen.py | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/Lib/compiler/pycodegen.py b/Lib/compiler/pycodegen.py index 55d2617923..92eff6cc68 100644 --- a/Lib/compiler/pycodegen.py +++ b/Lib/compiler/pycodegen.py @@ -825,11 +825,33 @@ class CodeGenerator: self.emit('POP_TOP') self.emit('POP_TOP') if target: - self.visit(target) + cleanup_body = self.newBlock() + cleanup_final = self.newBlock() + target_name = target[1] + + self.storeName(target_name) + self.emit('POP_TOP') + self.emit('SETUP_FINALLY', cleanup_final) + self.nextBlock(cleanup_body) + self.setups.push((TRY_FINALLY, cleanup_body)) + self.visit(body) + self.emit('POP_BLOCK') + self.setups.pop() + self.emit('LOAD_CONST', None) + self.nextBlock(cleanup_final) + self.setups.push((END_FINALLY, cleanup_final)) + + + self.emit('LOAD_CONST', None) + self.storeName(target_name) + self._implicitNameOp('DELETE', target_name) + + self.emit('END_FINALLY') + self.setups.pop() else: self.emit('POP_TOP') - self.emit('POP_TOP') - self.visit(body) + self.emit('POP_TOP') + self.visit(body) self.emit('JUMP_FORWARD', end) if expr: self.nextBlock(next) |