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 techtonik
Recipients techtonik
Date 2012-12-26.00:15:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1356480950.95.0.0708133666827.issue16781@psf.upfronthosting.co.za>
In-reply-to
Content
When a Python file is exec()uted, it magically fails to find names in imported modules. The most magical thing in the examples below (b3.py in attach for Python 3) is that first reference to wintypes.LONG in print statement is actually successfull.

--- a.py
from ctypes import wintypes

print(wintypes.LONG)

class LOGFONT(object):
  field = wintypes.LONG


--- b2.py (Python 2 version)
def main():
  execfile('a.py')
main()


--- Output
<class 'ctypes.c_long'>
Traceback (most recent call last):
  File "b2.py", line 4, in <module>
    main()
  File "b2.py", line 2, in main
    execfile('a.py')
  File "a.py", line 5, in <module>
    class LOGFONT(object):
  File "a.py", line 6, in LOGFONT
    field = wintypes.LONG
NameError: name 'wintypes' is not defined
History
Date User Action Args
2012-12-26 00:15:51techtoniksetrecipients: + techtonik
2012-12-26 00:15:50techtoniksetmessageid: <1356480950.95.0.0708133666827.issue16781@psf.upfronthosting.co.za>
2012-12-26 00:15:50techtoniklinkissue16781 messages
2012-12-26 00:15:48techtonikcreate