New submission from Drekin:
Let's have a simple script test.py:
def f():
return x
x = 2
print(f())
Now if we try to run it via runpy.run_path, we get the following:
import runpy
g = runpy.run_path(test.py)
2
g[f]() is None
True
g[x] is 2
True
g[f].__globals__[x] is None
True
Is
Changes by R. David Murray rdmur...@bitdance.com:
--
nosy: +ncoghlan
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18331
___
___
Python-bugs-list
Richard Oudkerk added the comment:
When modules are garbage collected the associated globals dict is purged -- see
#18214. This means that all values (except __builtins__) are replaced by None.
To work around this run_path() apparently returns a *copy* of the globals dict
which was created