[New-bugs-announce] [issue18331] runpy.run_path gives functions with corrupted .__globals__

Drekin report at bugs.python.org
Sun Jun 30 16:33:02 CEST 2013

New submission from Drekin:

Let's have a simple script test.py:
def f():
	return x
x = 2

Now if we try to run it via runpy.run_path, we get the following:
>>> import runpy
>>> g = runpy.run_path("test.py")
>>> g["f"]() is None
>>> g["x"] is 2
>>> g["f"].__globals__["x"] is None

Is the behaviour of f.__globals__ after return from run_path intended and why?

components: Library (Lib)
messages: 192072
nosy: Drekin
priority: normal
severity: normal
status: open
title: runpy.run_path gives functions with corrupted .__globals__
type: behavior
versions: Python 3.3

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list