Bug report
When having a lot of opened files, glob can return an empty list rather than either raising an error or returning a non-empty list.
With a ulimit set at 256 (ulimit -n 256), and with a file named foo:
fromglobimportglobprint(glob("*")) # expectedly prints files in current folderhandles= [(xforxinopen("foo")) for_inrange(253)] # create 253 file handles on fooprint(len(handles)) # returns 253print(glob("*")) # prints []My intuition is that glob should inform the user that it couldn't do its job properly (like open raises OSError if we try to open too many files), because right now there's an uncertainty on whether a given folder is empty or ulimit -n has been reached.
An OSError is caught in glob.py, but not propagated: https://github.com/python/cpython/blob/3.11/Lib/glob.py#L172
Your environment
- CPython versions tested on: 3.10, 3.11
- Operating system and architecture: macOS 12.0.1 (for 3.10), Debian 11 (for 3.11, from docker's
python:latest), both x86_64
Linked PRs
Bug report
When having a lot of opened files, glob can return an empty list rather than either raising an error or returning a non-empty list.
With a
ulimitset at 256 (ulimit -n 256), and with a file namedfoo:My intuition is that
globshould inform the user that it couldn't do its job properly (likeopenraisesOSErrorif we try to open too many files), because right now there's an uncertainty on whether a given folder is empty orulimit -nhas been reached.An OSError is caught in
glob.py, but not propagated: https://github.com/python/cpython/blob/3.11/Lib/glob.py#L172Your environment
python:latest), both x86_64Linked PRs