[issue33635] OSError when using pathlib.Path.rglob() to list device files
Ronald Oussoren
report at bugs.python.org
Sun May 27 07:17:24 EDT 2018
Ronald Oussoren <ronaldoussoren at mac.com> added the comment:
This is fairly odd behaviour of macOS, the same error can be seen from a bash session:
$ stat /dev/fd/3
stat: /dev/fd/3: stat: Bad file descriptor
The reason os.walk() works while the Path().is_file doesn't is that os.walk() explicitly guards against OSError exceptions raised by os.stat().
Looking at the documentation this could be seen as a bug in macOS, as the manual page for stat(2) doesn't mention EBADF as a valid error for this system call.
I'm not sure at this point if we should add a workaround for this. An actual patch would be easy enough, "just" add EBADF to the list of ignored errno values in the implementation of is_file (and related method) in pathlib.py
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33635>
_______________________________________
More information about the Python-bugs-list
mailing list