Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
barneygale mannequin opened this issue Mar 29, 2020 · 2 comments
Closed

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

barneygale mannequin opened this issue Mar 29, 2020 · 2 comments
Labels
3.10 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@barneygale
Copy link
Mannequin

barneygale mannequin commented Mar 29, 2020

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']

    @barneygale
    Copy link
    Mannequin Author

    barneygale mannequin commented Mar 29, 2020

    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.

    @barneygale barneygale mannequin added 3.9 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Mar 29, 2020
    @zooba
    Copy link
    Member

    zooba commented Apr 9, 2021

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

    @zooba zooba added 3.10 only security fixes and removed 3.9 only security fixes labels Apr 9, 2021
    @zooba zooba closed this as completed Apr 9, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant