Skip to content

Remove pathlib accessors #87178

Description

@barneygale
BPO 43012
Nosy @pitrou, @ericvsmith, @merwok, @encukou, @eryksun, @miss-islington, @barneygale
PRs
  • bpo-43012: remove pathlib._Accessor #25701
  • 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 = <Date 2022-02-02.15:37:05.067>
    created_at = <Date 2021-01-23.18:15:55.455>
    labels = ['3.11', 'library', 'performance']
    title = 'Remove pathlib accessors'
    updated_at = <Date 2022-02-02.15:37:05.063>
    user = 'https://github.com/barneygale'

    bugs.python.org fields:

    activity = <Date 2022-02-02.15:37:05.063>
    actor = 'eric.araujo'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-02-02.15:37:05.067>
    closer = 'eric.araujo'
    components = ['Library (Lib)']
    creation = <Date 2021-01-23.18:15:55.455>
    creator = 'barneygale'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43012
    keywords = ['patch']
    message_count = 4.0
    messages = ['385556', '410732', '410733', '412353']
    nosy_count = 7.0
    nosy_names = ['pitrou', 'eric.smith', 'eric.araujo', 'petr.viktorin', 'eryksun', 'miss-islington', 'barneygale']
    pr_nums = ['25701']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue43012'
    versions = ['Python 3.11']

    Activity

    1. barneygale commented on Jan 23, 2021

      barneygalemannequin
      MannequinAuthor

      Per Pitrou:

      The original intent for the “accessor” thing was to have a variant that did all accesses under a filesystem tree in a race condition-free way using openat and friends. It turned out to be much too hairy to actually implement, so was entirely abandoned, but the accessor abstraction was left there.

      https://discuss.python.org/t/make-pathlib-extensible/3428/2

      Accessors are:

      • Lacking any internal purpose - '_NormalAccessor' is the only implementation
      • Lacking any firm conceptual difference to Path objects themselves (inc. subclasses)
      • Non-public, i.e. underscore prefixed - '_Accessor' and '_NormalAccessor'
      • Unofficially used to implement customized Path objects, but once once bpo-24132 lands there will be a supported route for that.

      When bpo-24132 lands, I think we're free to remove accessors and simplify some code

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Jan 23, 2021
    3. merwok commented on Jan 16, 2022

      @merwok
      Member

      PR looks good, just needs a look by a pathlib expert.

    4. barneygale commented on Jan 16, 2022

      barneygalemannequin
      MannequinAuthor

      Thank you Éric!

    5. miss-islington commented on Feb 2, 2022

      @miss-islington
      Contributor

      New changeset 08f8301 by Barney Gale in branch 'main':
      bpo-43012: remove pathlib._Accessor (GH-25701)
      08f8301

    6. transferred this issue fromon Apr 10, 2022
    7. ronf commented on May 28, 2022

      @ronf
      Contributor

      This change is actually causing a problem for me. I have a unit test case which mocks out os.path.expanduser() but not the pathlib version. This works in 3.10 and earlier due to the indirection of the accessors, but in 3.11 the code ends up failing, since now the pathlib version of expanduser() is also getting into my mock.

      I wonder if there might be other code out there which also might be depending on this behavior, without even realizing it.

    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.11only security fixesperformancePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directory

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions