diff options
author | Alexey Izbyshev <izbyshev@ispras.ru> | 2018-10-20 00:28:22 (GMT) |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2018-10-20 00:28:22 (GMT) |
commit | 834603112e6ca35944dd21105b01fca562dc3241 (patch) | |
tree | 9f4b6f18381528cba38610d214c4422572e572bc /Lib/test/test_os.py | |
parent | a2670565d8f5c502388378aba1fe73023fd8c8d4 (diff) | |
download | cpython-834603112e6ca35944dd21105b01fca562dc3241.zip cpython-834603112e6ca35944dd21105b01fca562dc3241.tar.gz cpython-834603112e6ca35944dd21105b01fca562dc3241.tar.bz2 |
bpo-32890, os: Use errno instead of GetLastError() in execve() and truncate() (GH-5784)
path_error() uses GetLastError() on Windows, but some os functions
are implemented via CRT APIs which report errors via errno.
This may result in raising OSError with invalid error code (such
as zero).
Introduce posix_path_error() function and use it where appropriate.
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r-- | Lib/test/test_os.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 6dbc255..3f6e48f 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -1589,6 +1589,16 @@ class ExecTests(unittest.TestCase): with self.assertRaises(ValueError): os.execve(args[0], args, newenv) + @unittest.skipUnless(sys.platform == "win32", "Win32-specific test") + def test_execve_with_empty_path(self): + # bpo-32890: Check GetLastError() misuse + try: + os.execve('', ['arg'], {}) + except OSError as e: + self.assertTrue(e.winerror is None or e.winerror != 0) + else: + self.fail('No OSError raised') + @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests") class Win32ErrorTests(unittest.TestCase): |