Joachim B Haga wrote:
>> Since changing this would break class definitions, that ain't going to
>> happen. Suggestions for how to explain the behaviour more clearly in the
>> exec() documentation probably wouldn't hurt though.
>
> I don't quite see how exec() affects the class definition syntax?
Nick Coghlan writes:
> Joachim B Haga wrote:
>> There seem to be an inconsistency in the handling of local scopes in
>> exec. [...]
>>
>> The intermediate scope is searched for the variable name if the third
>> argument to exec() is locals(), but not if it is locals().copy().
>
> What actually m
Joachim B Haga wrote:
> There seem to be an inconsistency in the handling of local scopes in
> exec. Consider the following code, which raises NameError if the '#' is
> removed from the second last line.
>
>
> block = """
> b = 'ok'
> def f():
> print(b)# raises NameError here
> f()
> """