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 mistakenly assumes os.getcwd() is a resolved path in Windows · Issue #87621 · python/cpython

pathlib mistakenly assumes os.getcwd() is a resolved path in Windows #87621

New issue
Copy link
New issue
Copy link
Closed
Closed
pathlib mistakenly assumes os.getcwd() is a resolved path in Windows#87621
Copy link
Labels
3.10 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifeOS-windowsstdlibStandard 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

@eryksun
eryksun
opened on Mar 9, 2021
Issue body actions
BPO 43455
Nosy @pfmoore, @tjguk, @zware, @eryksun, @zooba, @uranusjr
PRs
  • bpo-38671: Make sure to return an absolute path in pathlib._WindowsFlavour.resolve() #17716
  • 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-03-09.23:05:56.225>
    labels = ['type-bug', '3.8', '3.9', '3.10', 'library', 'OS-windows']
    title = 'pathlib mistakenly assumes os.getcwd() is a resolved path in Windows'
    updated_at = <Date 2022-03-03.10:05:28.651>
    user = 'https://github.com/eryksun'

    bugs.python.org fields:

    activity = <Date 2022-03-03.10:05:28.651>
    actor = 'uranusjr'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)', 'Windows']
    creation = <Date 2021-03-09.23:05:56.225>
    creator = 'eryksun'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43455
    keywords = ['patch']
    message_count = 2.0
    messages = ['388393', '414415']
    nosy_count = 6.0
    nosy_names = ['paul.moore', 'tim.golden', 'zach.ware', 'eryksun', 'steve.dower', 'uranusjr']
    pr_nums = ['17716']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue43455'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    Activity

    1. eryksun commented on Mar 9, 2021

      @eryksun
      eryksun
      on Mar 9, 2021
      ContributorAuthor
      More actions

      pathlib._WindowsFlavour.resolve() mistakenly assume that os.getcwd() returns a resolved path in Windows:

          s = str(path)
          if not s:
              return os.getcwd()

      I don't think this is a practical problem since str(path) should never be an empty string. But if there is a concern that the result is an empty string, the code should use s = str(path) or '.', and resolve "." like any other relative path.

      In POSIX the result of getcwd() "shall contain no components that are dot or dot-dot, or are symbolic links". In Windows, os.getcwd() calls WinAPI GetCurrentDirectoryW(), which returns a fully-qualified path that may contain symbolic components that would be resolved in a final path. This includes filesystem symlinks and bind mounts (junctions), as well as mapped and substitute drives (i.e. drives that resolve to a filesystem directory instead of a volume device).

    2. eryksun
      added
      3.8 (EOL)end of lifeend of life
      3.9 (EOL)end of lifeend of life
      3.10 (EOL)end of lifeend of life
      stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
      OS-windows
      type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
      on Mar 9, 2021
    3. uranusjr commented on Mar 3, 2022

      @uranusjr
      uranusjrmannequin
      on Mar 3, 2022
      Mannequin
      More actions

      I believe this has been fixed in #25264

    4. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    5. brettcannon
      added
      topic-pathlib
      on Jun 21, 2022
    6. barneygale commented on Jul 23, 2022

      @barneygale
      barneygale
      on Jul 23, 2022
      Contributor
      More actions

      Hey @eryksun, could you check whether this is valid after #25264 was merged? Pathlib now calls ntpath.realpath(), which (from scanning the code) doesn't appear to suffer from this bug.

    7. terryjreedy
      added this to IDLE Issues and removed this from IDLE Issueson Jul 23, 2022
    8. eryksun commented on Jul 24, 2022

      @eryksun
      eryksun
      on Jul 24, 2022
      ContributorAuthor
      More actions

      I never had a practical case for not s, since it's at least ".". Anyway, this is a non-issue now. It was only kept open for 3.8 and 3.9, and the last bugfix for 3.9 was released on 2022-05-17.

    9. eryksun
      closed this as completedon Jul 24, 2022
    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.10 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifeOS-windowsstdlibStandard 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

      No projects

        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.