From 5f780400572508a8179de6a6c13b58b7be417ef5 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sat, 20 Nov 2010 18:07:52 +0000 Subject: [PATCH] add filename to ENOENT message #4925 --- Lib/subprocess.py | 2 ++ Lib/test/test_subprocess.py | 1 + Misc/ACKS | 1 + Misc/NEWS | 3 +++ 4 files changed, 7 insertions(+) diff --git a/Lib/subprocess.py b/Lib/subprocess.py index d699ed07ce..b40d2a8a2e 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -1255,6 +1255,8 @@ class Popen(object): errno = int(hex_errno, 16) if errno != 0: err_msg = os.strerror(errno) + if errno == errno.ENOENT: + err_msg += ': ' + repr(args[0]) raise child_exception_type(errno, err_msg) raise child_exception_type(err_msg) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 1a9fb69516..f8ecb4d543 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -666,6 +666,7 @@ class POSIXProcessTestCase(BaseTestCase): # string and instead capture the exception that we want to see # below for comparison. desired_exception = e + desired_exception.strerror += ': ' + repr(sys.executable) else: self.fail("chdir to nonexistant directory %s succeeded." % nonexistent_dir) diff --git a/Misc/ACKS b/Misc/ACKS index 9c003e988e..d61f953479 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -726,6 +726,7 @@ Ilya Sandler Mark Sapiro Ty Sarna Ben Sayer +Andrew Schaaf Michael Scharf Andreas Schawo Neil Schemenauer diff --git a/Misc/NEWS b/Misc/NEWS index 693f4e6a94..da26317d17 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ What's New in Python 3.2 Beta 1? Core and Builtins ----------------- +- Issue #4925: Add filename to error message when executable can't be found in + subprocess. + - Issue #1574217: isinstance now catches only AttributeError, rather than masking all errors. -- 2.50.1