--- test_sys.py.81920 2010-07-05 19:24:26.000000000 +0100 +++ test_sys.py 2010-07-05 23:48:47.000000000 +0100 @@ -513,6 +513,50 @@ self.assert_(b"UnicodeEncodeError:" in stderr, "%r not in %s" % (b"UniodeEncodeError:", ascii(stderr))) + def test_argv_correctly_decoded(self): + # Issue #9167: double-encoding on OS-X. + import subprocess + snowman = '\u2603' + p = subprocess.Popen( + [sys.executable, "-c", + 'import sys; print(sys.argv[-1].encode("utf8"))', + snowman], + stdout = subprocess.PIPE) + out = p.communicate()[0].strip() + self.assertEqual(b"b'\\xe2\\x98\\x83'", out) + + def test_executable_correctly_decoded(self): + # Issue #9167: double-encoding on OS-X. + import shutil + import tempfile + import subprocess + + # Create a temp dir with unicode in the path. + dir = tempfile.mkdtemp() + try: + snowman = '\u2603' + try: + os.mkdir(os.path.join(dir, snowman)) + except: # more specific? + self.skipTest("unicode path not supported") + + # Have a python executable in the test dir + exc = os.path.join(dir, snowman, os.path.basename(sys.executable)) + copy = getattr(os, "symlink", shutil.copy) + copy(sys.executable, exc) + + # Read how the executable appears in sys.executable + p = subprocess.Popen( + [exc, "-c", + 'import sys; print(sys.executable.encode("utf8"))'], + stdout = subprocess.PIPE) + out = p.communicate()[0].strip() + self.assertEqual(out, + repr(exc.encode('utf8')).encode('utf8')) + + finally: + shutil.rmtree(dir, ignore_errors=True) + def test_sys_flags(self): self.assertTrue(sys.flags) attrs = ("debug", "division_warning",