Skip to content

readlink for pathlib paths #74803

Closed
Closed

Description

@smheidrich
mannequin
BPO 30618
Nosy @gpshead, @pitrou, @berkerpeksag, @timofurrer, @miss-islington, @girtsf
PRs
  • bpo-30618: add readlink to pathlib.Path #8285
  • 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/gpshead'
    closed_at = <Date 2019-10-23.22:37:43.806>
    created_at = <Date 2017-06-09.23:55:59.670>
    labels = ['type-feature', 'library', '3.9']
    title = 'readlink for pathlib paths'
    updated_at = <Date 2019-10-23.22:37:43.804>
    user = 'https://bugs.python.org/smheidrich'

    bugs.python.org fields:

    activity = <Date 2019-10-23.22:37:43.804>
    actor = 'gregory.p.smith'
    assignee = 'gregory.p.smith'
    closed = True
    closed_date = <Date 2019-10-23.22:37:43.806>
    closer = 'gregory.p.smith'
    components = ['Library (Lib)']
    creation = <Date 2017-06-09.23:55:59.670>
    creator = 'smheidrich'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 30618
    keywords = ['patch']
    message_count = 5.0
    messages = ['295592', '320335', '324364', '355266', '355271']
    nosy_count = 9.0
    nosy_names = ['gregory.p.smith', 'pitrou', 'spatz', 'planet36', 'berker.peksag', 'tuxtimo', 'smheidrich', 'miss-islington', 'girts']
    pr_nums = ['8285']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'commit review'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue30618'
    versions = ['Python 3.9']

    Activity

    1. smheidrich commented on Jun 9, 2017

      smheidrichmannequin
      MannequinAuthor

      Is there any reason why there is no equivalent of os.readlink in pathlib.Path? Note that Path.resolve does *not* fit the bill, as it always produces an absolute path, whereas readlink just spits out the symlink target exactly the way it is stored, which may be relative to the symlink itself:

      >>> import pathlib, os
      >>> p = pathlib.Path("/lib64/libc.so.6")
      >>> p.resolve()
      PosixPath('/lib64/libc-2.24.so')
      >>> os.readlink(str(p))
      'libc-2.24.so'
    2. added
      3.7 (EOL)
      stdlib
      type-feature
      on Jun 9, 2017
    3. girtsf commented on Jun 23, 2018

      girtsfmannequin
      Mannequin

      Just ran into the same thing. I would be interested in adding support for a "readlink" call if a pull request on this would be welcome.

    4. berkerpeksag commented on Aug 30, 2018

      @berkerpeksag
      Member

      The resolve() method already solves symlinks, but I think this is a reasonable feature request. I've just reviewed PR 8285.

    5. added
      3.8 (EOL)
      and removed
      3.7 (EOL)
      on Aug 30, 2018
    6. added
      3.9 (EOL)
      and removed
      3.8 (EOL)
      on Jul 20, 2019
    7. self-assigned this
      on Oct 23, 2019
    8. miss-islington commented on Oct 23, 2019

      @miss-islington
      Contributor

      New changeset a01ba33 by Miss Skeleton (bot) (Girts) in branch 'master':
      bpo-30618: add readlink to pathlib.Path (GH-8285)
      a01ba33

    9. gpshead commented on Oct 23, 2019

      @gpshead
      Member

      Thanks Girts!

    10. 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

    Labels

    3.9 (EOL)stdlibtype-feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions