[issue4381] Cannot declare multiple classes via exec when inside a function.

2008-11-21 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment: I agree that it is confusing; in short: a bare exec() does not play well with closures; This is a consequence of the python execution model, and is unlikely to change. Here, the class 'foo' is stored in the function's local variables

[issue4381] Cannot declare multiple classes via exec when inside a function.

2008-11-21 Thread Kevin Fitch
New submission from Kevin Fitch <[EMAIL PROTECTED]>: 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: