Skip to content

Remove pathlib flavours #88302

Description

@barneygale
BPO 44136
Nosy @pitrou, @barneygale
PRs
  • bpo-44136: remove pathlib._Flavour #26141
  • bpo-44412: add os.path.fileuri() function. #26708
  • bpo-44136: pathlib: merge _Flavour.make_uri() into PurePath.as_uri() #30320
  • bpo-44136: pathlib: merge _Flavour.is_reserved() into PurePath.is_reserved() #30321
  • gh-68320, gh-88302 - Allow for pathlib.Path subclassing #31691
  • 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/pitrou'
    closed_at = None
    created_at = <Date 2021-05-14.18:28:58.393>
    labels = ['type-bug', 'library', '3.11']
    title = 'Remove pathlib flavours'
    updated_at = <Date 2022-03-05.02:18:42.694>
    user = 'https://github.com/barneygale'

    bugs.python.org fields:

    activity = <Date 2022-03-05.02:18:42.694>
    actor = 'barneygale'
    assignee = 'pitrou'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2021-05-14.18:28:58.393>
    creator = 'barneygale'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44136
    keywords = ['patch']
    message_count = 3.0
    messages = ['393685', '395759', '413857']
    nosy_count = 2.0
    nosy_names = ['pitrou', 'barneygale']
    pr_nums = ['26141', '26708', '30320', '30321', '31691']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue44136'
    versions = ['Python 3.11']

    Activity

    1. barneygale commented on May 14, 2021

      barneygalemannequin
      MannequinAuthor

      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.

    2. added
      3.11only security fixes
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on May 14, 2021
    3. barneygale commented on Jun 13, 2021

      barneygalemannequin
      MannequinAuthor
    4. barneygale commented on Feb 23, 2022

      barneygalemannequin
      MannequinAuthor

      ^ just to bring my previous comment up-to-date:

      I'm no longer pursuing adding os.path.isreserved() and os.path.fileuri() functions, or modifying normpath(). At least, not for now!

      Instead, my plan is to move flavour functionality as follows (as classmethods with underscore prefixes):

      _Flavour --> PurePath
      _PosixFlavour --> PurePath
      _WindowsFlavour --> PureWindowsPath

      As a result, PurePath will use POSIX syntax by default. This is fully backwards-compatible, as users can't create PurePath objects! PurePath.__new__() instantiates PurePosixPath or PureWindowsPath. But it will matter for future user subclasses of PurePath/Path, where we usually want POSIX syntax.

      I think there will be three PRs involved. PR 30320 and PR 30321 move _Flavour.make_uri() and _Flavour.is_reserved() respectively; these are reasonably standalone. If/when they land, I'll make a larger PR that moves the remaining methods into PurePath and PureWindowsPath.

    5. transferred this issue fromon Apr 10, 2022
    6. added a commit that references this issue on Dec 23, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions