[Python-checkins] cpython: Remove misleading comment and code.
antoine.pitrou
python-checkins at python.org
Tue Aug 30 18:37:19 CEST 2011
http://hg.python.org/cpython/rev/b5a5bd429580
changeset: 72137:b5a5bd429580
parent: 72134:b21b0e1478bf
user: Antoine Pitrou <solipsis at pitrou.net>
date: Tue Aug 30 18:34:47 2011 +0200
summary:
Remove misleading comment and code.
Windows does set the errno attribute to ENOENT, but the error message
displays the Windows error number (3 -> ERROR_PATH_NOT_FOUND), not the
errno number (2 -> ENOENT).
The Unix errno corresponding to 3 is ESRCH, explaining the confusion,
which can be seen in the following snippet:
>>> shutil.rmtree("foo")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "Z:\default\lib\shutil.py", line 272, in rmtree
onerror(os.listdir, path, sys.exc_info())
File "Z:\default\lib\shutil.py", line 270, in rmtree
names = os.listdir(path)
WindowsError: [Error 3] The system cannot find the path specified:
'foo\\*.*'
>>> e = sys.last_value
>>> e.errno
2
>>> e.winerror
3
>>> errno.errorcode[2]
'ENOENT'
For reference, see PC/errmap.h and
http://msdn.microsoft.com/en-us/library/ms681382%28v=vs.85%29.aspx
files:
Lib/test/support.py | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/Lib/test/support.py b/Lib/test/support.py
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -212,8 +212,7 @@
try:
shutil.rmtree(path)
except OSError as error:
- # Unix returns ENOENT, Windows returns ESRCH.
- if error.errno not in (errno.ENOENT, errno.ESRCH):
+ if error.errno != errno.ENOENT:
raise
def make_legacy_pyc(source):
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list