mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
bpo-22536 [3.6] Set filename in FileNotFoundError (#3305)
* [3.6] bpo-22536: Set the filename in FileNotFoundError. (GH-3194)
Have the subprocess module set the filename in the FileNotFoundError
exception raised on POSIX systems when the executable or cwd are missing.
(cherry picked from commit 8621bb5d93
)
* bpo-22536 [3.6] (GH-3202) skip non-windows tests.
This commit is contained in:
parent
703fdb837a
commit
1dba3789e3
3 changed files with 20 additions and 6 deletions
|
@ -1328,15 +1328,15 @@ class Popen(object):
|
|||
child_exec_never_called = (err_msg == "noexec")
|
||||
if child_exec_never_called:
|
||||
err_msg = ""
|
||||
# The error must be from chdir(cwd).
|
||||
err_filename = cwd
|
||||
else:
|
||||
err_filename = orig_executable
|
||||
if errno_num != 0:
|
||||
err_msg = os.strerror(errno_num)
|
||||
if errno_num == errno.ENOENT:
|
||||
if child_exec_never_called:
|
||||
# The error must be from chdir(cwd).
|
||||
err_msg += ': ' + repr(cwd)
|
||||
else:
|
||||
err_msg += ': ' + repr(orig_executable)
|
||||
raise child_exception_type(errno_num, err_msg)
|
||||
err_msg += ': ' + repr(err_filename)
|
||||
raise child_exception_type(errno_num, err_msg, err_filename)
|
||||
raise child_exception_type(err_msg)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue