GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [pathlib] Option so that OSError does not block glob in pathlib library · Issue #90208 · python/cpython

[pathlib] Option so that OSError does not block glob in pathlib library #90208

New issue
Copy link
New issue
Copy link
Closed
Closed
[pathlib] Option so that OSError does not block glob in pathlib library#90208
Copy link
Labels
3.8 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-pathlibtype-featureA feature request or enhancementA feature request or enhancement

Description

matt32106
mannequin
opened on Dec 11, 2021
Issue body actions
BPO 46050
Nosy @matt32106

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 = None
closed_at = None
created_at = <Date 2021-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 = <Date 2021-12-11.16:25:35.541>
user = 'https://github.com/matt32106'

bugs.python.org fields:

activity = <Date 2021-12-11.16:25:35.541>
actor = 'matt32106'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2021-12-11.16:25:35.541>
creator = 'matt32106'
dependencies = []
files = []
hgrepos = []
issue_num = 46050
keywords = []
message_count = 1.0
messages = ['408314']
nosy_count = 1.0
nosy_names = ['matt32106']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue46050'
versions = ['Python 3.8']

Linked PRs

  • GH-90208: Suppress OSError exceptions from pathlib.Path.glob() #104141

Activity

  1. matt32106 commented on Dec 11, 2021

    @matt32106
    matt32106mannequin
    on Dec 11, 2021
    MannequinAuthor
    More actions

    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...


    /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:

    class _WildcardSelector(_Selector):
        def _select_from(self, parent_path, is_dir, exists, scandir):
            (...)
            except OSError:
                return
    
    class _RecursiveWildcardSelector(_Selector):
        def _iterate_directories(self, parent_path, is_dir, scandir):
            (...)
            except OSError:
                return

    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?!

  2. matt32106
    added
    3.8 (EOL)end of lifeend of life
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    type-featureA feature request or enhancementA feature request or enhancement
    on Dec 11, 2021
  3. ezio-melotti
    transferred this issue fromon Apr 10, 2022
  4. serhiy-storchaka
    added this to Fnmatch and glob issueson May 19, 2022
  5. brettcannon
    added
    topic-pathlib
    on Jun 21, 2022
  6. barneygale commented on May 3, 2023

    @barneygale
    barneygale
    on May 3, 2023
    Contributor
    More actions

    IMO it should ignore all OSError exceptions that are generated below the top-level path. PR incoming...

  7. barneygale
    added 5 commits that reference this issue on May 3, 2023

    pythonGH-90208 - Suppress OSError exceptions from `pathlib.Path.glob()`

    f884b3f

    Merge branch 'main' into pythongh-90208-pathlib-glob-oserror-ignore

    1b7cbb7

    Merge branch 'main' into pythongh-90208-pathlib-glob-oserror-ignore

    a59709c

    Merge branch 'main' into pythongh-90208-pathlib-glob-oserror-ignore

    0054195

    GH-90208: Suppress OSError exceptions from `pathlib.Path.glob()` (GH-…

    94f30c7
  8. barneygale commented on May 11, 2023

    @barneygale
    barneygale
    on May 11, 2023
    Contributor
    More actions

    Fixed in #104141 / 94f30c7

  9. barneygale
    closed this as completedon May 11, 2023
  10. github-project-automation
    moved this to Done in Fnmatch and glob issueson May 11, 2023
  11. carljm
    added 2 commits that reference this issue on May 11, 2023

    Merge branch 'main' into supermon

    19b3d9e

    Merge branch 'main' into fixloadsuperspec

    4456dd6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.8 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-pathlibtype-featureA feature request or enhancementA feature request or enhancement

    Projects

    • Fnmatch and glob issues
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.