Rob,
(apologies for delay - message stuck in queue)

On 31/03/2026 00:31, Rob Cliffe via Python-list wrote:
I am using Python 3.13 and Windows 11.
I have a RAM disk (ImDisk), configured to be the R: drive.
When the RAM disc is empty,
     os.scandir("R:")
raises a FileNotFoundError instead of (as I would have expected) returning an empty iterator. Whereas for an empty directory on a hard drive or memory stick, os.scandir() does indeed return an empty iterator.

The keywords here seem to be "drive" and "directory".

https://docs.python.org/3/library/os.html#os.scandir
«
 os.scandir(path='.')

Return an iterator of os.DirEntry objects corresponding to the entries in the directory given by path. The entries are yielded in arbitrary order, and the special entries '.' and '..' are not included. If a file is removed from or added to the directory after creating the iterator, whether an entry for that file be included is unspecified.
»

Instead of using the bare drive-letter, try adding the root-directory explicitly, ie R:\\ or R:/

(without access to an MS-Win machine, unable to check this)


PS obligatory advice/interference: recommend trying pathlib's Path.walk() - wonder if it returns same err.msg?


This does seem to be a defect of os.scandir.
Can it be fixed?

Best wishes
Rob Cliffe
--
Regards,
=dn

--
https://mail.python.org/mailman3//lists/python-list.python.org

Reply via email to