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.PureWindowsPath comparison results vary between Windows and Posix · Issue #104947 · python/cpython

pathlib.PureWindowsPath comparison results vary between Windows and Posix #104947

New issue
Copy link
New issue
Copy link
Closed
Closed
pathlib.PureWindowsPath comparison results vary between Windows and Posix#104947
Copy link
Labels
3.12only security fixesonly security fixes3.13only security fixesonly security fixestopic-pathlibtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@barneygale
barneygale
opened on May 25, 2023
Issue body actions

In #31691 I switched pathlib.PureWindowsPath comparisons to use os.path.normcase() rather than str.lower(). This is probably a mistake, as @eryksun points out:

The inconsistency is with ntpath.normcase() on Windows. It's probably for the best if the pure comparison methods revert to using str.lower() for the sake of consistency, not only with glob() and match(), but also with using PureWindowsPath on POSIX. Maybe platform-dependent comparisons could be implemented on Path.

On Windows, ntpath.normcase() is based on LCMapStringEx(). It turns out that this function implements a case mapping for some non-BMP characters. WinAPI CompareStringOrdinal(), on the other hand, has no case mapping for non-BMP characters, which is consistent with Microsoft's filesystems. Thus I'd prefer for a platform-dependent comparison to use CompareStringOrdinal() instead of LCMapStringEx().

Linked PRs

  • GH-104947: Make pathlib.PureWindowsPath comparisons consistent across platforms #104948
  • [3.12] GH-104947: Make pathlib.PureWindowsPath comparisons consistent across platforms (GH-104948) #104990

Activity

  1. barneygale
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    3.12only security fixesonly security fixes
    topic-pathlib
    3.13only security fixesonly security fixes
    on May 25, 2023
  2. barneygale
    added 2 commits that reference this issue on May 25, 2023

    pythonGH-104947: Make pathlib.PureWindowsPath comparisons consistent …

    256e1ee

    GH-104947: Make pathlib.PureWindowsPath comparisons consistent across…

    ad0be36
  3. miss-islington
    added a commit that references this issue on May 26, 2023

    pythonGH-104947: Make pathlib.PureWindowsPath comparisons consistent …

    0b5ccbb
  4. barneygale
    added a commit that references this issue on May 26, 2023

    [3.12] GH-104947: Make pathlib.PureWindowsPath comparisons consistent…

    eca102d
  5. barneygale commented on May 26, 2023

    @barneygale
    barneygale
    on May 26, 2023
    ContributorAuthor
    More actions

    Thanks for spotting this @eryksun. It's fixed in:

    • ad0be36 / GH-104947: Make pathlib.PureWindowsPath comparisons consistent across platforms #104948
    • eca102d / [3.12] GH-104947: Make pathlib.PureWindowsPath comparisons consistent across platforms (GH-104948) #104990

    3.12 beta 2 will contain the fix.

  6. barneygale
    closed this as completedon May 26, 2023
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.12only security fixesonly security fixes3.13only security fixesonly security fixestopic-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.