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.Path.glob() does not list dangling symlink when pattern is the exact filename · Issue #89769 · python/cpython

pathlib.Path.glob() does not list dangling symlink when pattern is the exact filename #89769

New issue
Copy link
New issue
Copy link
Closed
Closed
pathlib.Path.glob() does not list dangling symlink when pattern is the exact filename#89769
Copy link
Assignees
akulakov
Labels
3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-pathlibtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

raek
mannequin
opened on Oct 25, 2021
Issue body actions
BPO 45606
Nosy @Fidget-Spinner, @akulakov, @raek
PRs
  • GH-89769: Pathlib - do not follow links when checking for precise glob match #29655
  • 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 = 'https://github.com/akulakov'
    closed_at = None
    created_at = <Date 2021-10-25.19:20:55.106>
    labels = ['type-bug', 'library', '3.9', '3.10', '3.11']
    title = 'pathlib.Path.glob() does not list dangling symlink when pattern is the exact filename'
    updated_at = <Date 2022-01-23.06:57:12.913>
    user = 'https://github.com/raek'

    bugs.python.org fields:

    activity = <Date 2022-01-23.06:57:12.913>
    actor = 'andrei.avk'
    assignee = 'andrei.avk'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2021-10-25.19:20:55.106>
    creator = 'raek'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45606
    keywords = ['patch']
    message_count = 4.0
    messages = ['404996', '406643', '406644', '406645']
    nosy_count = 3.0
    nosy_names = ['kj', 'andrei.avk', 'raek']
    pr_nums = ['29655']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue45606'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    Activity

    Next
    1. raek commented on Oct 25, 2021

      @raek
      raekmannequin
      on Oct 25, 2021
      MannequinAuthor
      More actions

      Create a symlink that points to file that doesn't exist:

      ln -s /nonexisting_file my_symlink
      

      Then try to glob for that symlink from Python using pathlib:

          python3
          >>> import pathlib
          >>> list(pathlib.Path(".").glob("my_symlink"))
          []
          >>> list(pathlib.Path(".").glob("my_symlink*"))
          [PosixPath('my_symlink')]

      I'm a bit surprised that these two globs do not return the same results. Personally I would expect both to find the symlink.

      Is this behaviour a bug or is it intentional?

    2. raek
      added
      3.8 (EOL)end of lifeend of life
      3.10 (EOL)end of lifeend of life
      3.9 (EOL)end of lifeend of life
      stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
      on Oct 25, 2021
    3. akulakov commented on Nov 20, 2021

      @akulakov
      akulakov
      on Nov 20, 2021
      Contributor
      More actions

      The issue is that _PreciseSelector follows the symlink when it checks if a path exists before yielding it as a result.

      I've put up a PR with a fix; I've also added a follow_symlinks arg to exists() method because it seems more logical to be able to test if a path exists via the same method rather than having to also remember and to check for it being a symlink.

      I will add docs and news a bit later today or tomorrow.

    4. akulakov
      assigned
      akulakov
      on Nov 20, 2021
    5. akulakov commented on Nov 20, 2021

      @akulakov
      akulakov
      on Nov 20, 2021
      Contributor
      More actions

      Rasmus: thanks for the report, it does seem like a bug to me.

    6. 3 remaining items

    7. akulakov
      changed the title [-]pathlib.Path.glob() does not list dangling symlink when pattern is the exact filenane[/-] [+]pathlib.Path.glob() does not list dangling symlink when pattern is the exact filename[/+] on Jan 23, 2022
    8. akulakov
      added
      3.11only security fixesonly security fixes
      and removed
      3.8 (EOL)end of lifeend of life
      on Jan 23, 2022
    9. akulakov
      changed the title [-]pathlib.Path.glob() does not list dangling symlink when pattern is the exact filenane[/-] [+]pathlib.Path.glob() does not list dangling symlink when pattern is the exact filename[/+] on Jan 23, 2022
    10. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    11. serhiy-storchaka
      added this to Fnmatch and glob issueson May 19, 2022
    12. brettcannon
      added
      topic-pathlib
      on Jun 21, 2022
    13. barneygale
      added a commit that references this issue on May 3, 2023

      GH-89769: `pathlib.Path.glob()`: do not follow symlinks when checking…

      af886ff
    14. barneygale commented on May 3, 2023

      @barneygale
      barneygale
      on May 3, 2023
      Contributor
      More actions

      Fixed in 3.12: #29655 / af886ff

    15. barneygale
      closed this as completedon May 3, 2023
    16. github-project-automation
      moved this to Done in Fnmatch and glob issueson May 3, 2023
    17. barneygale
      added
      3.12only security fixesonly security fixes
      and removed
      3.11only security fixesonly security fixes
      3.10 (EOL)end of lifeend of life
      3.9 (EOL)end of lifeend of life
      on May 3, 2023
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    • @akulakov
      akulakov

    Labels

    3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-pathlibtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    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.