#1690103: fix initial namespace for code run with trace.main().
This commit is contained in:
parent
920bc0fd86
commit
8f9f466505
|
@ -799,7 +799,14 @@ def main(argv=None):
|
||||||
try:
|
try:
|
||||||
with open(progname) as fp:
|
with open(progname) as fp:
|
||||||
code = compile(fp.read(), progname, 'exec')
|
code = compile(fp.read(), progname, 'exec')
|
||||||
t.run(code)
|
# try to emulate __main__ namespace as much as possible
|
||||||
|
globs = {
|
||||||
|
'__file__': progname,
|
||||||
|
'__name__': '__main__',
|
||||||
|
'__package__': None,
|
||||||
|
'__cached__': None,
|
||||||
|
}
|
||||||
|
t.runctx(code, globs, globs)
|
||||||
except IOError as err:
|
except IOError as err:
|
||||||
_err_exit("Cannot run file %r because: %s" % (sys.argv[0], err))
|
_err_exit("Cannot run file %r because: %s" % (sys.argv[0], err))
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
|
|
|
@ -15,6 +15,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #1690103: Fix initial namespace for code run with trace.main().
|
||||||
|
|
||||||
- Issue #7395: Fix tracebacks in pstats interactive browser.
|
- Issue #7395: Fix tracebacks in pstats interactive browser.
|
||||||
|
|
||||||
- Issue #8230: Fix Lib/test/sortperf.py.
|
- Issue #8230: Fix Lib/test/sortperf.py.
|
||||||
|
|
Loading…
Reference in New Issue