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 — Support recursive wildcards in pathlib.PurePath.match() · Issue #73435 · python/cpython

Support recursive wildcards in pathlib.PurePath.match() #73435

New issue
Copy link
New issue
Copy link
Closed
Closed
Support recursive wildcards in pathlib.PurePath.match()#73435
Copy link
Labels
3.7 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifedocsDocumentation in the Doc dirDocumentation in the Doc dirtopic-pathlibtype-featureA feature request or enhancementA feature request or enhancement

Description

JonWalsh
mannequin
opened on Jan 12, 2017
Issue body actions
BPO 29249
Nosy @pitrou, @RonnyPfannschmidt, @serhiy-storchaka, @wimglenn, @JulienPalard, @virtuald, @andunai, @barneygale, @eumiro

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 2017-01-12.10:19:54.004>
labels = ['3.8', 'type-feature', '3.7', '3.9', 'docs']
title = 'Pathlib glob ** bug'
updated_at = <Date 2021-06-04.19:42:17.687>
user = 'https://bugs.python.org/JonWalsh'

bugs.python.org fields:

activity = <Date 2021-06-04.19:42:17.687>
actor = 'christian.heimes'
assignee = 'docs@python'
closed = False
closed_date = None
closer = None
components = ['Documentation']
creation = <Date 2017-01-12.10:19:54.004>
creator = 'Jon Walsh'
dependencies = []
files = []
hgrepos = []
issue_num = 29249
keywords = []
message_count = 11.0
messages = ['285297', '285305', '285308', '285311', '285323', '307854', '307866', '325735', '361147', '382535', '386795']
nosy_count = 12.0
nosy_names = ['pitrou', 'docs@python', 'Ronny.Pfannschmidt', 'serhiy.storchaka', 'wim.glenn', 'mdk', 'virtuald', 'Jon Walsh', 'Andrew Dunai', 'Isaac Muse', 'barneygale', 'eumiro']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'needs patch'
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue29249'
versions = ['Python 3.5', 'Python 3.6', 'Python 3.7', 'Python 3.8', 'Python 3.9']

Linked PRs

  • GH-73435: Implement recursive wildcards in pathlib.PurePath.match() #101398
  • GH-73435: Add pathlib.PurePath.full_match() #114350

Activity

Next
  1. JonWalsh commented on Jan 12, 2017

    @JonWalsh
    JonWalshmannequin
    on Jan 12, 2017
    MannequinAuthor
    More actions
    >>> from pathlib import Path
    >>> Path("a/b/c/d/e.txt").match('a/*/**/*')
    False
  2. JonWalsh
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Jan 12, 2017
  3. andunai commented on Jan 12, 2017

    @andunai
    andunaimannequin
    on Jan 12, 2017
    Mannequin
    More actions

    Isn't this intended? According to https://docs.python.org/2/library/glob.html and wiki, typical UNIX glob pattern does not have the reqursive matching operator (**).

  4. tiran commented on Jan 12, 2017

    @tiran
    tiran
    on Jan 12, 2017
    Member
    More actions

    The ticket is not about glob but about pathlib.

    Pathlib supports ** directory globbing, but it's only documented as prefix globbing, https://docs.python.org/3/library/pathlib.html#pathlib.Path.glob

  5. serhiy-storchaka commented on Jan 12, 2017

    @serhiy-storchaka
    serhiy-storchaka
    on Jan 12, 2017
    Member
    More actions

    ** is supported not just as a prefix. Path('./Lib').glob('**/.py') emits the same paths as Path('.').glob('Lib/**/.py'). But ** is supported only in glob(), not in match(). The support of ** in match() is not documented. Would be worth to document explicitly that it is not supported.

  6. serhiy-storchaka
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    3.7 (EOL)end of lifeend of life
    and removed
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Jan 12, 2017
  7. serhiy-storchaka
    assigned
    docspython
    on Jan 12, 2017
  8. serhiy-storchaka
    added
    type-featureA feature request or enhancementA feature request or enhancement
    and removed
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Jan 12, 2017
  9. JonWalsh commented on Jan 12, 2017

    @JonWalsh
    JonWalshmannequin
    on Jan 12, 2017
    MannequinAuthor
    More actions

    Seems a bit strange to not have glob() and match() working the same though. Is there any reason for that?

    Reacted by cccs-dm
  10. virtuald commented on Dec 8, 2017

    @virtuald
    virtualdmannequin
    on Dec 8, 2017
    Mannequin
    More actions

    I just ran into this also. It seems like a very strange omission that match and glob don't support the same patterns (and I'm surprised that they don't share more code).

  11. virtuald commented on Dec 8, 2017

    @virtuald
    virtualdmannequin
    on Dec 8, 2017
    Mannequin
    More actions

    Because of backwards compatibility (despite a statement saying it's not guaranteed for pathlib), I think the best approach would be to create a 'globmatch' function for PurePath instead of modifying the match function, and document that the match function does a different kind of matching.

    This isn't a patch for cpython per se (ironically, don't have time for that this month...), but here's a MIT-licensed gist that patches pathlib2 and adds a globmatch function to it, plus associated tests extracted from pathlib2 and my own ** related tests. Works for me, feel free to do with it as you wish.

    https://gist.github.com/virtuald/dd0373bf3f26ec0730adf1da0fb929bb

  12. 24 remaining items

  13. barneygale
    added 4 commits that reference this issue on May 27, 2023

    Merge branch 'main' into pythongh-73435-pathlib-match-recursive

    8959dfd

    Merge branch 'main' into pythongh-73435-pathlib-match-recursive

    fec7702

    Merge branch 'main' into pythongh-73435-pathlib-match-recursive

    89bc380

    GH-73435: Implement recursive wildcards in `pathlib.PurePath.match()` (…

    49f90ba
  14. barneygale commented on May 30, 2023

    @barneygale
    barneygale
    on May 30, 2023
    Contributor
    More actions

    Thanks for your patience all. This is now implemented in 49f90ba / #101398, and will become available in Python 3.13!

    Reacted by Yannick PÉROUX, Nicholas Hairs and Labs
  15. barneygale
    closed this as completedon May 30, 2023
  16. github-project-automation
    moved this to Done in Fnmatch and glob issueson May 30, 2023
  17. barneygale commented on Jan 20, 2024

    @barneygale
    barneygale
    on Jan 20, 2024
    Contributor
    More actions

    Re-opening. I'm beginning to think that the implied **/ prefix limits the usefulness of this method, as it makes it impossible to match relative paths from the left hand side, and makes it subtly incompatible with glob().

    I'm going to put up a PR that reverts match() back to 3.12 behaviour, and instead adds a globmatch() method.

  18. barneygale
    reopened this on Jan 20, 2024
  19. barneygale
    added 2 commits that reference this issue on Jan 20, 2024

    pythonGH-73435: Add `pathlib.PurePath.globmatch()`

    1c8bf81

    GH-73435: Add `pathlib.PurePath.full_match()` (#114350)

    b69548a
  20. barneygale commented on Jan 26, 2024

    @barneygale
    barneygale
    on Jan 26, 2024
    Contributor
    More actions

    Re-resolving. This is now implemented as PurePath.full_match()

  21. barneygale
    closed this as completedon Jan 26, 2024
  22. aisk
    added a commit that references this issue on Feb 11, 2024

    pythonGH-73435: Add `pathlib.PurePath.full_match()` (python#114350)

    3a7ecb0
  23. Glyphack
    added a commit that references this issue on Sep 2, 2024

    pythonGH-73435: Add `pathlib.PurePath.full_match()` (python#114350)

    f7bece1
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.7 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifedocsDocumentation in the Doc dirDocumentation in the Doc dirtopic-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.