diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-18 17:17:23 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-18 17:17:23 (GMT) |
commit | b745a74c99b9db0daab7289c6a1f0e386cd26644 (patch) | |
tree | 3dd5e45a9311372a36ad280e3c1739ab573cdf9e /Lib/test/test_subprocess.py | |
parent | 04b5684d002de5e3eb4232bb287c6884afb61bf3 (diff) | |
download | cpython-b745a74c99b9db0daab7289c6a1f0e386cd26644.zip cpython-b745a74c99b9db0daab7289c6a1f0e386cd26644.tar.gz cpython-b745a74c99b9db0daab7289c6a1f0e386cd26644.tar.bz2 |
Issue #8513: os.get_exec_path() supports b'PATH' key and bytes value.
subprocess.Popen() and os._execvpe() support bytes program name. Add
os.supports_bytes_environ flag: True if the native OS type of the environment
is bytes (eg. False on Windows).
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r-- | Lib/test/test_subprocess.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index eb96706..96c8ebf 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -825,6 +825,27 @@ class POSIXProcessTestCase(BaseTestCase): stdout = stdout.rstrip(b'\n\r') self.assertEquals(stdout.decode('ascii'), repr(value)) + def test_bytes_program(self): + abs_program = os.fsencode(sys.executable) + path, program = os.path.split(sys.executable) + program = os.fsencode(program) + + # absolute bytes path + exitcode = subprocess.call([abs_program, "-c", "pass"]) + self.assertEquals(exitcode, 0) + + # bytes program, unicode PATH + env = os.environ.copy() + env["PATH"] = path + exitcode = subprocess.call([program, "-c", "pass"], env=env) + self.assertEquals(exitcode, 0) + + # bytes program, bytes PATH + envb = os.environb.copy() + envb[b"PATH"] = os.fsencode(path) + exitcode = subprocess.call([program, "-c", "pass"], env=envb) + self.assertEquals(exitcode, 0) + @unittest.skipUnless(mswindows, "Windows specific tests") class Win32ProcessTestCase(BaseTestCase): |