[issue36243] Python os.listdir fails with FileNotFoundError when directory exists

Geoff Alexander report at bugs.python.org
Sat Mar 9 02:06:51 EST 2019


Geoff Alexander <gdlxn at us.ibm.com> added the comment:

This problem does not appear to be a race condition ("Time Of Check To Time Of Use" bug) in my case as the directory in question exists both before and after the os.listdir call.

I got a workaround saying to wrap the os.listdir call in try/except in my Stack Overflow question at https://stackoverflow.com/questions/55067904/python-os-listdir-fails-with-filenotfounderror-when-directory-exists.  This worked as no longer got any spurious FileNotFound exceptions.

I realize that the code snippet I gave is not runnable.  I'll look to put together a small example illustrating the problem and add to the issue.

----------
status: pending -> open

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36243>
_______________________________________


More information about the Python-bugs-list mailing list