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 kfitch
Recipients kfitch
Date 2008-11-21.20:33:43
SpamBayes Score 1.171202e-11
Marked as misclassified No
Message-id <1227299625.55.0.683059455596.issue4381@psf.upfronthosting.co.za>
In-reply-to
Content
codeText = """ class foo(object): pass class bar(object): baz = foo() """ def doExec(text): exec text ### This works: # Although if I do this before the doExec below, then the # doExec doesn't fail. # exec codeText ### But this does not: doExec(codeText) The output I get is: --------------------------------------------------------------------------- <type 'exceptions.NameError'> Traceback (most recent call last) /home/kfitch/<ipython console> in <module>() /home/kfitch/<ipython console> in doExec(text) /home/kfitch/<string> in <module>() /home/kfitch/<string> in bar() <type 'exceptions.NameError'>: name 'foo' is not defined I don't fully understand why the version in the function doesn't work, but I suspect it is a bug related to scoping, since foo is really doExec.foo (I think). This is with python 2.5.2 under Linux (Ubuntu 8.04)
History
Date User Action Args
2008-11-21 20:33:45kfitchsetrecipients: + kfitch
2008-11-21 20:33:45kfitchsetmessageid: <1227299625.55.0.683059455596.issue4381@psf.upfronthosting.co.za>
2008-11-21 20:33:45kfitchlinkissue4381 messages
2008-11-21 20:33:44kfitchcreate