[issue18331] runpy.run_path gives functions with corrupted .__globals__

2013-06-30 Thread Drekin
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

[issue18331] runpy.run_path gives functions with corrupted .__globals__

2013-06-30 Thread R. David Murray
Changes by R. David Murray rdmur...@bitdance.com: -- nosy: +ncoghlan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18331 ___ ___ Python-bugs-list

[issue18331] runpy.run_path gives functions with corrupted .__globals__

2013-06-30 Thread Richard Oudkerk
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