[Patches] [ python-Patches-1638243 ] compiler.pycodegen causes crashes when compiling 'with'

SourceForge.net noreply at sourceforge.net
Thu Jan 18 04:52:36 CET 2007


Patches item #1638243, was opened at 2007-01-17 22:52
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1638243&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Parser/Compiler
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: kirat (kirat)
Assigned to: Nobody/Anonymous (nobody)
Summary: compiler.pycodegen causes crashes when compiling 'with'

Initial Comment:
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


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1638243&group_id=5470


More information about the Patches mailing list