This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: compiler.pycodegen causes crashes when compiling 'with'
Type: Stage:
Components: Interpreter Core Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, kirat
Priority: normal Keywords: patch

Created on 2007-01-18 03:52 by kirat, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
diffs.txt kirat, 2007-01-18 03:52 compiler patch for with code generation
Messages (2)
msg51765 - (view) Author: kirat (kirat) Date: 2007-01-18 03:52
The compiler package in the python library is missing a LOAD/DELETE just before the WITH_CLEANUP instruction.

Also transformer isn't creating the with_var as an assignment.

So the following little code snippet will crash if you compile and run it with compiler.compile()

class TrivialContext:
    def __enter__(self): return self
    def __exit__(self,*exc_info): pass

def f():
    with TrivialContext() as tc:
        return 1
f()

The fix is just a few lines. I'm enclosing a patch against the python 2.5 source.

I've also added the above as a test case to the test_compiler.py file.

regards,
-Kirat
msg51766 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-01-27 17:43
Thanks for the patch, this is fixed now in rev. 53575, 53576 (2.5).
History
Date User Action Args
2022-04-11 14:56:22adminsetgithub: 44487
2007-01-18 03:52:36kiratcreate