Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 398356b

Browse files
author
Victor Stinner
committed
Improve error message if the command is not decodable
1 parent 7e44b6b commit 398356b

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

Lib/test/test_sys.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,10 @@ def test_main_invalid_unicode(self):
509509
p = subprocess.Popen([sys.executable, "-c", code], stderr=subprocess.PIPE)
510510
stdout, stderr = p.communicate()
511511
self.assertEqual(p.returncode, 1)
512-
self.assertIn(br"UnicodeEncodeError:", stderr)
512+
lines = stderr.splitlines()
513+
self.assertGreaterEqual(len(lines), 2)
514+
self.assertEqual(b"Unable to decode the command from the command line:", lines[0])
515+
self.assertIn(br"UnicodeEncodeError:", lines[1])
513516

514517
def test_sys_flags(self):
515518
self.assertTrue(sys.flags)

Modules/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ run_command(wchar_t *command, PyCompilerFlags *cf)
275275
return ret != 0;
276276

277277
error:
278+
PySys_WriteStderr("Unable to decode the command from the command line:\n");
278279
PyErr_Print();
279280
return 1;
280281
}

0 commit comments

Comments
 (0)