Bugs item #1748015, was opened at 2007-07-04 19:53 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1748015&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: Python Interpreter Core Group: Python 2.5 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Nefarious CodeMonkey, Jr. (nejucomo) Assigned to: Nobody/Anonymous (nobody) Summary: Module-level stack scopes have incorrect bindings. Initial Comment: For a variable defined in a module scope, and stack frame object's locals and globals scope dictionaries each contain that variables name mapped to None. This confuses python code which inspects the bindings, such as pdb. Such code incorrectly reports the value as None. It may be that the binding values are correct at the time of exception generation, but altered by the time the exception traceback is caught. This problem may also be related to module imports. Here's are two simple examples, the first does not trigger this problem, the second does. Both use this module called "buggy.py": # Begin buggy.py whatKnightsSay = 'Ni!' print 'We are the Knights who say: %r' % (whatKnightsSay,) 42 + whatKnightsSay # End buggy.py # Begin a non-failing example: $ pdb buggy.py > /home/n/sandbox/python-module-binding-bug-src/buggy.py(1)<module>() -> whatKnightsSay = 'Ni!' (Pdb) print whatKnightsSay *** NameError: name 'whatKnightsSay' is not defined (Pdb) next > /home/n/sandbox/python-module-binding-bug-src/buggy.py(2)<module>() -> print 'We are the Knights who say: %r' % (whatKnightsSay,) (Pdb) print whatKnightsSay Ni! (Pdb) next We are the Knights who say: 'Ni!' > /home/n/sandbox/python-module-binding-bug-src/buggy.py(3)<module>() -> 42 + whatKnightsSay (Pdb) print whatKnightsSay Ni! (Pdb) next TypeError: "unsupported operand type(s) for +: 'int' and 'str'" > /home/n/sandbox/python-module-binding-bug-src/buggy.py(3)<module>() -> 42 + whatKnightsSay (Pdb) print whatKnightsSay Ni! (Pdb) next --Return-- > /home/n/sandbox/python-module-binding-bug-src/buggy.py(3)<module>()->None -> 42 + whatKnightsSay (Pdb) print whatKnightsSay Ni! (Pdb) next TypeError: "unsupported operand type(s) for +: 'int' and 'str'" > <string>(1)<module>()->None (Pdb) print whatKnightsSay Ni! # End succeeding example. And here's a simple failing example, which relies on a second module: # Begin triggerPdb.py import pdb pdb.set_trace() import buggy # End triggerPdb.py Now pdb get's confused about the module level binding: # Begin failure example: $ python triggerPdb.py > /home/n/sandbox/python-module-binding-bug-src/triggerPdb.py(3)<module>() -> import buggy (Pdb) next We are the Knights who say: 'Ni!' TypeError: "unsupported operand type(s) for +: 'int' and 'str'" > /home/n/sandbox/python-module-binding-bug-src/triggerPdb.py(3)<module>() -> import buggy (Pdb) down > /home/n/sandbox/python-module-binding-bug/buggy.py(3)<module>() -> 42 + whatKnightsSay (Pdb) list 1 whatKnightsSay = 'Ni!' 2 print 'We are the Knights who say: %r' % (whatKnightsSay,) 3 -> 42 + whatKnightsSay [EOF] (Pdb) p whatKnightsSay None # End failing example. I've included these two simple sources, as well as another that does traceback inspection in an except clause (which fails like the second example here). ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1748015&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com