bpo-32852: Fix trace changing sys.argv to tuple. (GH-5692)
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py
index 1d87aea..e04ca01 100644
--- a/Lib/test/test_trace.py
+++ b/Lib/test/test_trace.py
@@ -387,5 +387,15 @@
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()
diff --git a/Lib/trace.py b/Lib/trace.py
index 48a1d1b..ade7616 100755
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -705,7 +705,7 @@
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,