summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-02-16 23:14:41 -0800
committerGitHub <noreply@github.com>2018-02-16 23:14:41 -0800
commitdda938683c48197ab7e775144136f433a5d43103 (patch)
treeff85eda0448b7802a4ce88b9cad5dd0bbf8d58a7 /Lib
parentf2d2e6169eb31e1a223d29d5de07e80939939106 (diff)
downloadcpython-git-dda938683c48197ab7e775144136f433a5d43103.tar.gz
bpo-32852: Fix trace changing sys.argv to tuple. (GH-5692)
(cherry picked from commit 9f4223261fd129ad7b9a09b2b0d625d1bb90b22b) Co-authored-by: Kyle Altendorf <sda@fstab.net>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_trace.py10
-rwxr-xr-xLib/trace.py2
2 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py
index 1d87aea5a3..e04ca01c42 100644
--- a/Lib/test/test_trace.py
+++ b/Lib/test/test_trace.py
@@ -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()
diff --git a/Lib/trace.py b/Lib/trace.py
index ae154615fa..9ba9486bd0 100755
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -710,7 +710,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,