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: Where does "self._flavour" comes from? (3.11 to 3.12 migration) · Issue #104921 · python/cpython

pathlib: Where does "self._flavour" comes from? (3.11 to 3.12 migration) #104921

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
pathlib: Where does "self._flavour" comes from? (3.11 to 3.12 migration)#104921
Copy link
Labels
3.12only security fixesonly security fixespendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-pathlib

Description

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

This question is related to Python 3.12.

cpython/Lib/pathlib.py

Line 319 in 278030a

self._raw_path = self._flavour.join(*paths)

This is the first occurrence of self._flavour in pathlib.py. I don't see where this object is set. I can't find the string self._flavour = somewhere in the repo. I'm confused.

Background:
I try to figuring out why pathlib._Flavour.parse_parts() (and the whole class) was removed from Python 3.11 to 3.12. I can not see this in the CHANGELOG. And I'm not skilled enough with git to find the related commit.

Reacted by Barney Gale

Activity

  1. hugovk
    added
    topic-pathlib
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    3.12only security fixesonly security fixes
    on May 25, 2023
  2. hugovk commented on May 25, 2023

    @hugovk
    hugovk
    on May 25, 2023
    Member
    More actions

    Thank you for testing the beta!

    pathlib._Flavour was removed in #31691.

    The linked issues are gh-68320, gh-88302. From the latter:

    Following bpo-39899, bpo-43757 and bpo-43012, pathlib._Flavour and its subclasses are looking a bit pointless.

    The implementations of is_reserved() and make_uri() (~as_uri()) can be readily moved to into PurePosixPath and PureWindowsPath, which removes some indirection. This follows the pattern of OS-specific stuff in PosixPath and WindowsPath.

    The remaining methods, such as splitroot(), can be pulled into Pure*Path with an underscore prefix.

    I'm generally a believer in composition over inheritance, but in this case _Flavour seems too small and too similar to PurePath to separate out into 3 extra classes.

    There should be no impact on public APIs or performance.

    I expect there was no CHANGELOG entry because the undescores indicate these are private and not part of the public API, and pyfakefs will need refactoring to use something else.

    cc @barneygale


    PS I did git log -S _Flavour Lib/pathlib.py to find the most recent commit mentioning the class, including deletes.

  3. hugovk
    added
    pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
    on May 25, 2023
  4. CAM-Gerlach commented on May 25, 2023

    @CAM-Gerlach
    CAM-Gerlach
    on May 25, 2023
    Member
    More actions

    Also, just to note, _parse_parts itself (likewise still a private method) was replaced with _parse_path in PR #102789 , to address issues #76846 and #85281 . Presumably, the intention is to properly subclass Path rather than relying on private internal-only members, though @barneygale is the expert and can likely advise you what's best for your use case much more specifically.

  5. buhtz commented on May 25, 2023

    @buhtz
    buhtz
    on May 25, 2023
    Author
    More actions

    Awesome! Great!
    Thanks a lot for helping and explaining. I learned a lot.

    From my point of view this Issue can be closed.

    Reacted by Hugo van Kemenade
  6. hugovk
    closed this as not plannedon May 25, 2023
  7. barneygale commented on May 29, 2023

    @barneygale
    barneygale
    on May 29, 2023
    Contributor
    More actions

    For posterity, the motivation/explanation for the removal of the flavour classes can be found here: https://discuss.python.org/t/make-pathlib-extensible/3428/42

    Reacted by Christian Buhtz
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 fixespendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-pathlib

    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.