[Python-bugs-list] Exec statement inconsistency (PR#175)

guido@CNRI.Reston.VA.US guido@CNRI.Reston.VA.US
Wed, 12 Jan 2000 17:39:24 -0500 (EST)


> It's been a long time since I thought I understood all the rules here --
> there are subtleties.  Still, it looks odd to me too that e.g.
> 
> def f():
>     x = 1
>     exec "x=x+1"
>     print x     # prints 2
> 
> def g():
>     x = 1
>     exec compile("x=x+1", "", "exec")
>     print x     # prints 1
> 
> f()
> g()
> 
> I'll leave that one for Guido to rationalize away <wink>!

*That* one's a bug -- the exec statement is supposed to sync back the
locals fron the dict to their fast form, but the code to do that is
only present when the argument is a string.  I'm fixing this as we
speak.

--Guido van Rossum (home page: http://www.python.org/~guido/)