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 r.david.murray
Recipients benjamin.peterson, r.david.murray, techtonik
Date 2012-12-26.01:25:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1356485104.3.0.927007765197.issue16781@psf.upfronthosting.co.za>
In-reply-to
Content
The fact that the print works should be a clue that Python is in fact finding the module and importing it.  So your problem actually has to do with namespaces, which is something you have to think about when using exec or execfile.  You can see this by replacing your import with any variable setting (say, a=1) and referencing that in the class body.

The problem here is that execfile is operating inside a function, therefore the local and global namespaces are different.  wintypes gets imported into the *local* namespace.

Now, if you inline this type of code by hand, wintypes (or a) is found in the local namespace when the class statement is executed.  But when it is done via execfile, it is not.  

I'm not clear on whether or not this is a bug, but if it isn't there is certainly missing documentation in the description of execfile.
History
Date User Action Args
2012-12-26 01:25:04r.david.murraysetrecipients: + r.david.murray, techtonik, benjamin.peterson
2012-12-26 01:25:04r.david.murraysetmessageid: <1356485104.3.0.927007765197.issue16781@psf.upfronthosting.co.za>
2012-12-26 01:25:04r.david.murraylinkissue16781 messages
2012-12-26 01:25:02r.david.murraycreate