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 — Document exceptions raised by fnmtach · Issue #89973 · python/cpython

Document exceptions raised by fnmtach #89973

New issue
Copy link
New issue
Copy link
Closed
#93072
Closed
Document exceptions raised by fnmtach#89973
#93072
Copy link
Assignees
serhiy-storchaka
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-regex

Description

DimitriPapadopoulos
mannequin
opened on Nov 16, 2021
Issue body actions
BPO 45815
Nosy @ezio-melotti, @DimitriPapadopoulos
Files
  • sre_constants.error_stderr.txt: Last part of the stderr output of a Python script that calls fnmatch() on a bad glob
  • 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-11-16.10:46:44.748>
    labels = ['expert-regex', '3.11', 'library', 'docs']
    title = 'Document exceptions raised by fnmtach'
    updated_at = <Date 2021-11-16.10:46:44.748>
    user = 'https://github.com/DimitriPapadopoulos'

    bugs.python.org fields:

    activity = <Date 2021-11-16.10:46:44.748>
    actor = 'DimitriPapadopoulosOrfanos'
    assignee = 'docs@python'
    closed = False
    closed_date = None
    closer = None
    components = ['Documentation', 'Library (Lib)', 'Regular Expressions']
    creation = <Date 2021-11-16.10:46:44.748>
    creator = 'DimitriPapadopoulosOrfanos'
    dependencies = []
    files = ['50442']
    hgrepos = []
    issue_num = 45815
    keywords = []
    message_count = 1.0
    messages = ['406396']
    nosy_count = 4.0
    nosy_names = ['ezio.melotti', 'mrabarnett', 'docs@python', 'DimitriPapadopoulosOrfanos']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue45815'
    versions = ['Python 3.11']

    Linked PRs

    • gh-89973: Fix typo #139405

    Activity

    Next
    1. DimitriPapadopoulos commented on Nov 16, 2021

      @DimitriPapadopoulos
      DimitriPapadopoulosmannequin
      on Nov 16, 2021
      MannequinAuthor
      More actions

      The fnmatch documentation should explicitly mention the type of exceptions raised by fnmatch.fnmatch():
      https://docs.python.org/3/library/fnmatch.html

      In my case it raised sre_constants.error, and it took some time to understand that the proper way to catch this type of exceptions is to catch the re.error superclass, by reading https://bugs.python.org/issue795379.

      Actually that would be the case for any module using the re module under the hood, possibly passing an ill-formed regex to a re function.

    2. DimitriPapadopoulos
      added
      3.11only security fixesonly security fixes
      on Nov 16, 2021
    3. DimitriPapadopoulos
      assigned
      docspython
      on Nov 16, 2021
    4. DimitriPapadopoulos
      added
      docsDocumentation in the Doc dirDocumentation in the Doc dir
      stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
      topic-regex
      3.11only security fixesonly security fixes
      on Nov 16, 2021
    5. DimitriPapadopoulos
      assigned
      docspython
      on Nov 16, 2021
    6. DimitriPapadopoulos
      added
      docsDocumentation in the Doc dirDocumentation in the Doc dir
      stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
      topic-regex
      on Nov 16, 2021
    7. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    8. gpshead commented on Apr 14, 2022

      @gpshead
      gpshead
      on Apr 14, 2022
      Member
      More actions

      It'd also be reasonable for the fnmatch._compile_pattern function to be updated to catch re.error and internally and reraise ValueError. The only times this should happen are when the input pattern turns into an invalid regular expression so our code cannot use it. So in absense of us improving fnmatch's abilities, it is an error with the user supplied value.

      Or for maximum backwards compatibility, an fnmatch.PatternError class that inherits from both re.error and ValueError so that code can be written to catch either.

      Reacted by Mariatta
    9. serhiy-storchaka commented on Apr 15, 2022

      @serhiy-storchaka
      serhiy-storchaka
      on Apr 15, 2022
      Member
      More actions

      In what case it raises re.error?

    10. serhiy-storchaka
      added
      pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
      on Apr 21, 2022
    11. 15 remaining items

    12. DimitriPapadopoulos commented on May 4, 2022

      @DimitriPapadopoulos
      DimitriPapadopoulos
      on May 4, 2022
      Author
      More actions

      Still, it would be nice to:

      • either document that fnmatch() might raise a re.error if something goes wrong with pattern processing,
      • or catch re.error exceptions and raise a ValueError.

      Just in case...

    13. serhiy-storchaka
      added this to Fnmatch and glob issueson May 19, 2022
    14. serhiy-storchaka
      added a commit that references this issue on May 22, 2022

      pythongh-89973: Fix re.error in the fnmatch module.

      ab4b759
    15. serhiy-storchaka
      removed
      3.9 (EOL)end of lifeend of life
      on May 22, 2022
    16. serhiy-storchaka
      moved this to In Progress in Fnmatch and glob issueson May 22, 2022
    17. serhiy-storchaka
      closed this as completedin #93072on Jun 5, 2022
    18. Repository owner moved this from In Progress to Done in Fnmatch and glob issueson Jun 5, 2022
    19. miss-islington
      added a commit that references this issue on Jun 5, 2022

      pythongh-89973: Fix re.error in the fnmatch module. (pythonGH-93072)

      2210833
    20. serhiy-storchaka
      added a commit that references this issue on Jun 5, 2022

      gh-89973: Fix re.error in the fnmatch module. (GH-93072)

      0902c3d
    21. miss-islington
      added 3 commits that reference this issue on Jun 5, 2022

      pythongh-89973: Fix re.error in the fnmatch module. (pythonGH-93072)

      236c6c6

      gh-89973: Fix re.error in the fnmatch module. (GH-93072)

      2f8aae3

      gh-89973: Fix re.error in the fnmatch module. (GH-93072)

      2220dc5
    22. serhiy-storchaka
      added a commit that references this issue on Jun 26, 2022

      Revert 30935 defer bpo45162 to 312 (#94285)

      1ffde3e
    23. lazka
      added a commit that references this issue on Jun 26, 2022

      builtin cover: fix handling of invalid glob ranges with Python 3.10.5+

      5eb7c30
    24. declension
      added a commit that references this issue on Jun 26, 2022

      builtin cover: fix handling of invalid glob ranges with Python 3.10.5+ (

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

    Metadata

    Metadata

    Assignees

    • @serhiy-storchaka
      serhiy-storchaka

    Labels

    3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-regex

    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.