]> granicus.if.org Git - python/commitdiff
Improve error message if the command is not decodable
authorVictor Stinner <victor.stinner@haypocalc.com>
Wed, 18 Aug 2010 22:23:22 +0000 (22:23 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Wed, 18 Aug 2010 22:23:22 +0000 (22:23 +0000)
Lib/test/test_sys.py
Modules/main.c

index d2f5b85d2d9a28a1fd1bf1ffda36c9c862c37d5a..f146d71b7b678a3091e9b31665e959cd4a22156d 100644 (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)
index d129aba074c62574c5b45244588dce6f863f9c73..a5c89059d36c4da144061f21da301eee055728ec 100644 (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;
 }