Skip to content

pathlib: make _Accessor.open() return a file object and not a file descriptor #84288

Description

@barneygale
BPO 40107
Nosy @zooba, @barneygale
PRs
  • bpo-40107: stop using os.open() to implement pathlib.Path.open() #25240
  • 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 2021-04-09.22:03:35.867>
    created_at = <Date 2020-03-29.22:37:39.513>
    labels = ['type-feature', 'library', '3.10']
    title = 'pathlib: make `_Accessor.open()` return a file object and not a file descriptor'
    updated_at = <Date 2021-04-09.22:03:35.867>
    user = 'https://github.com/barneygale'

    bugs.python.org fields:

    activity = <Date 2021-04-09.22:03:35.867>
    actor = 'steve.dower'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-04-09.22:03:35.867>
    closer = 'steve.dower'
    components = ['Library (Lib)']
    creation = <Date 2020-03-29.22:37:39.513>
    creator = 'barneygale'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40107
    keywords = ['patch']
    message_count = 2.0
    messages = ['365283', '390667']
    nosy_count = 2.0
    nosy_names = ['steve.dower', 'barneygale']
    pr_nums = ['25240']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue40107'
    versions = ['Python 3.10']

    Activity

    1. barneygale commented on Mar 29, 2020

      barneygalemannequin
      MannequinAuthor

      This is one of a series of bug reports / PRs that lay the groundwork for making pathlib extensible. See here for detail: https://discuss.python.org/t/make-pathlib-extensible/3428

      Currently _Accessor.open() is expected to function like os.open() and return a file descriptor. I'd suggest this interface is too low-level if our eventual aim is to allow users to implement their own accessor.

      It would be better is _Accessor.open() is expected to function like io.open() and return a file object. That way, accessors don't need to deal with file descriptors at all, which is important if they're working with remote filesystems.

      I'm planning to wait for bpo-39895 / #63038 to land before starting work on this.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-featureA feature request or enhancement
      on Mar 29, 2020
    3. zooba commented on Apr 9, 2021

      @zooba
      Member

      New changeset 11c3bd3 by Barney Gale in branch 'master':
      bpo-40107: Switch to using io.open() for pathlib.Path.open() (GH-25240)
      11c3bd3

    4. added and removed on Apr 9, 2021
    5. transferred this issue fromon Apr 10, 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 lifestdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions