Hello,

this is about a behaviour change of Python:

> -Exec with None as tuple args did update locals: 1
> > +Exec with None as tuple args did update locals: 0
>

Normally, "exec" only used to copy back to locals, if it was given no
argument, and using "locals()" in a read only fashion, when it's given as
"None".

In my attempt to fix it, I discovered that "None" now does the copy back,
while given "locals()" explicitly, does not, although "locals()" does not.

So:

def f1():
   f = 1
   exec("f=2")

  # f now 2

def f2():
   f = 1
   exec("f=2", None, None) # None, None defaults to globals, locals()

  # f now 2, but used to be 1

def f3():
   f = 1
   exec("f=2", globals(), locals())

  # f now 1

There is something called a "unqualified exec". And it appears that bit is
no longer used to determine if locals is a dictionary, and therefore
writable, or not. Apparently in f3 it is not, and in f2 it is.

I wonder, if this is really an upstream change, or maybe a Debian specific
change. Unfortunately, this will need more investigation and has no obvious
fix. I am going to check against baseline 2.7.8 now and report on that.

Yours,
Kay

Reply via email to