You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[pathlib] Option so that OSError does not block glob in pathlib library #90208
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2021-12-11.16:25:35.541>labels= ['3.8', 'type-feature', 'library']
title='[pathlib] Option so that OSError does not block glob in pathlib library'updated_at=<Date2021-12-11.16:25:35.541>user='https://github.com/matt32106'
/usr/lib/python3.8/pathlib.py(535)_select_from()
533 try:
534 with scandir(parent_path) as scandir_it:
--> 535 entries = list(scandir_it)
536 for entry in entries:
537 if self.dironly:
I also another case is if a cloud drive is disconnected.
QUICK SOLUTION
I solved both issues for me by adding an adding an except OSError: return at the end of the two function below:
FEATURE REQUEST
I don't know the consequences of those 2 modifications so perhaps they could follow an option when calling glob with an optional parameter ignoreOSerror = false by default?!
Activity
matt32106 commentedon Dec 11, 2021
Hi there,
ISSUE DESCRIPTION
when I browse starting from the linux root ('/')
path = pathlib.Path('/')
_glob = '**/*'
for p in path.glob(_glob):
The program stops on my machine because of OSError.
File "/usr/lib/python3.8/pathlib.py", line 535, in _select_from
entries = list(scandir_it)
OSError: [Errno 22] Invalid argument: '/proc/5916/task/5916/net'
Entering post mortem debugging...
I also another case is if a cloud drive is disconnected.
QUICK SOLUTION
I solved both issues for me by adding an adding an except OSError: return at the end of the two function below:
FEATURE REQUEST
I don't know the consequences of those 2 modifications so perhaps they could follow an option when calling glob with an optional parameter ignoreOSerror = false by default?!
barneygale commentedon May 3, 2023
IMO it should ignore all
OSErrorexceptions that are generated below the top-level path. PR incoming...pythonGH-90208 - Suppress OSError exceptions from `pathlib.Path.glob()`
Merge branch 'main' into pythongh-90208-pathlib-glob-oserror-ignore
Merge branch 'main' into pythongh-90208-pathlib-glob-oserror-ignore
Merge branch 'main' into pythongh-90208-pathlib-glob-oserror-ignore
GH-90208: Suppress OSError exceptions from `pathlib.Path.glob()` (GH-…
barneygale commentedon May 11, 2023
Fixed in #104141 / 94f30c7
Merge branch 'main' into supermon
Merge branch 'main' into fixloadsuperspec