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.

Author jerry.seutter
Recipients jerry.seutter
Date 2008-03-18.02:55:43
SpamBayes Score 0.19975154
Marked as misclassified No
Message-id <1205808945.1.0.883835206976.issue2378@psf.upfronthosting.co.za>
In-reply-to
Content
Found a bug when trying to integrate figleaf coverage into trunk.  I
have ripped the code down to the smallest subset that still causes the
behaviour.  The code works on the latest release of Python 2.5 but is
broken on trunk.  It comes in two files.  The first is the caller (figleaf):

import os
import sys

def foo(f, e, o):
    pass
    
sys.settrace(foo)

import __main__
execfile('test_broken.py', __main__.__dict__)



The second file is the test (test_broken.py):

# This code breaks on trunk

def test_foo():
    class CustomException(Exception):
        pass

    class SomeClass:
        def foo(self):
            raise CustomException

    # The error only appears with enough nested blocks.
    if (True == True):
        try:
            raise IOError
        except CustomException:
            pass



It should raise IOError.  When run, it gives the following output:

jerry-seutters-computer:~/code/python/core_wierd_bug_minimal jseutter$
../core/python.exe figleaf                
Traceback (most recent call last):
  File "figleaf", line 10, in <module>
    execfile('test_broken.py', __main__.__dict__)
  File "test_broken.py", line 18, in <module>
    test_foo()
  File "test_broken.py", line 15, in test_foo
    except CustomException:
UnboundLocalError: local variable 'CustomException' referenced before
assignment
[10019 refs]
History
Date User Action Args
2008-03-18 02:55:45jerry.seuttersetspambayes_score: 0.199752 -> 0.19975154
recipients: + jerry.seutter
2008-03-18 02:55:45jerry.seuttersetspambayes_score: 0.199752 -> 0.199752
messageid: <1205808945.1.0.883835206976.issue2378@psf.upfronthosting.co.za>
2008-03-18 02:55:44jerry.seutterlinkissue2378 messages
2008-03-18 02:55:44jerry.seuttercreate