bpo-32852: Fix trace changing sys.argv to tuple. (GH-5692)
This commit is contained in:
parent
243d6d7126
commit
9f4223261f
|
@ -387,5 +387,15 @@ class TestCommandLine(unittest.TestCase):
|
|||
status, stdout, stderr = assert_python_ok('-m', 'trace', '-l', TESTFN)
|
||||
self.assertIn(b'functions called:', stdout)
|
||||
|
||||
def test_sys_argv_list(self):
|
||||
with open(TESTFN, 'w') as fd:
|
||||
self.addCleanup(unlink, TESTFN)
|
||||
fd.write("import sys\n")
|
||||
fd.write("print(type(sys.argv))\n")
|
||||
|
||||
status, direct_stdout, stderr = assert_python_ok(TESTFN)
|
||||
status, trace_stdout, stderr = assert_python_ok('-m', 'trace', '-l', TESTFN)
|
||||
self.assertIn(direct_stdout.strip(), trace_stdout)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -705,7 +705,7 @@ def main():
|
|||
if opts.filename is None:
|
||||
parser.error('filename is missing: required with the main options')
|
||||
|
||||
sys.argv = opts.filename, *opts.arguments
|
||||
sys.argv = [opts.filename, *opts.arguments]
|
||||
sys.path[0] = os.path.dirname(opts.filename)
|
||||
|
||||
t = Trace(opts.count, opts.trace, countfuncs=opts.listfuncs,
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Make sure sys.argv remains as a list when running trace.
|
Loading…
Reference in New Issue