Improve error message if the command is not decodable

This commit is contained in:
Victor Stinner 2010-08-18 22:23:22 +00:00
parent 7e44b6b0c5
commit 398356baaa
2 changed files with 5 additions and 1 deletions

View File

@ -509,7 +509,10 @@ class SysModuleTest(unittest.TestCase):
p = subprocess.Popen([sys.executable, "-c", code], stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
self.assertEqual(p.returncode, 1)
self.assertIn(br"UnicodeEncodeError:", stderr)
lines = stderr.splitlines()
self.assertGreaterEqual(len(lines), 2)
self.assertEqual(b"Unable to decode the command from the command line:", lines[0])
self.assertIn(br"UnicodeEncodeError:", lines[1])
def test_sys_flags(self):
self.assertTrue(sys.flags)

View File

@ -275,6 +275,7 @@ run_command(wchar_t *command, PyCompilerFlags *cf)
return ret != 0;
error:
PySys_WriteStderr("Unable to decode the command from the command line:\n");
PyErr_Print();
return 1;
}