[New-bugs-announce] [issue12802] Windows error code 267 should be mapped to ENOTDIR, not EINVAL

Antoine Pitrou report at bugs.python.org
Sun Aug 21 02:46:30 CEST 2011


New submission from Antoine Pitrou <pitrou at free.fr>:

Windows error 3 is returned when a directory path doesn't exist, but 267 is returned when an existing path is not a directory. This corresponds straight to the definition of ENOTDIR, but Python translates it to EINVAL:

>>> os.listdir("xx")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
WindowsError: [Error 3] The system cannot find the path specified: 'xx\\*.*'

>>> os.listdir("LICENSE")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
WindowsError: [Error 267] The directory name is invalid: 'LICENSE\\*.*'

>>> os.chdir("LICENSE")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
WindowsError: [Error 267] The directory name is invalid: 'LICENSE'

>>> e = sys.last_value
>>> e.errno
22
>>> errno.errorcode[22]
'EINVAL'


In PC/errmap.h, no Windows error code is translated to ENOTDIR (errno 20).

----------
messages: 142589
nosy: amaury.forgeotdarc, brian.curtin, pitrou, tim.golden
priority: normal
severity: normal
stage: needs patch
status: open
title: Windows error code 267 should be mapped to ENOTDIR, not EINVAL
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12802>
_______________________________________


More information about the New-bugs-announce mailing list