Pewarta Proxy

📋 Server Request & Proxy Logs

Loading active proxy settings...
Developed by Khairul Adha (adhexa.id)
Mengambil log server...

⚙️ Pengaturan Proxy Target

Skip to content

Pathlib .owner() and .group() methods fail on broken links #65521

Closed

Description

@inigoserna
BPO 21322
Nosy @pitrou
Files
  • pathlib-34-owner_group_fixed.diff
  • 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 2017-11-09.18:11:28.341>
    created_at = <Date 2014-04-21.16:42:49.821>
    labels = ['library', 'type-crash']
    title = 'Pathlib .owner() and .group() methods fail on broken links'
    updated_at = <Date 2017-11-09.18:11:28.340>
    user = 'https://bugs.python.org/inigoserna'

    bugs.python.org fields:

    activity = <Date 2017-11-09.18:11:28.340>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-11-09.18:11:28.341>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2014-04-21.16:42:49.821>
    creator = 'inigoserna'
    dependencies = []
    files = ['34992']
    hgrepos = []
    issue_num = 21322
    keywords = ['patch']
    message_count = 4.0
    messages = ['216950', '216971', '216995', '216996']
    nosy_count = 2.0
    nosy_names = ['pitrou', 'inigoserna']
    pr_nums = []
    priority = 'normal'
    resolution = 'rejected'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue21322'
    versions = ['Python 3.4']

    Activity

    1. inigoserna commented on Apr 21, 2014

      inigosernamannequin
      MannequinAuthor

      Pathlib .owner() and .group() methods fail on broken symlinks.

      They use:
      return pwd.getpwuid(self.stat().st_uid).pw_name
      and:
      return grp.getgrgid(self.stat().st_gid).gr_name

      It should be self.lstat().

      Attached simple fix as unified diff.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-crashA hard crash of the interpreter, possibly with a core dump
      on Apr 21, 2014
    3. pitrou commented on Apr 21, 2014

      @pitrou
      Member

      Most other Path methods operate on the link target, not the link itself, so I don't see why these methods would work otherwise.

    4. inigoserna commented on Apr 22, 2014

      inigosernamannequin
      MannequinAuthor

      Mainly, 2 reasons:

      • It can make programs crash *unexpectedly*

      • Pathlib should provide a complete and uniform API for dealing with all types of files. If not, users would need to use Pathlib for some kind of files and go to os and os.path for others, then why the reason to use Pathlib?

    5. pitrou commented on Apr 22, 2014

      @pitrou
      Member
      • It can make programs crash *unexpectedly*

      A broken link is an error, so it's normal to have an exception raised
      here. An exception can always be caught if you were expecting the error.

      • Pathlib should provide a complete and uniform API for dealing with
        all types of files. If not, users would need to use Pathlib for some
        kind of files and go to os and os.path for others, then why the reason
        to use Pathlib?

      I sympathize with this. But you can already use Path.lstat() and inspect
      the st_uid and st_gid fields if you are really interested in the link's
      owner and group (rather than the target's).

      The fact that most Path methods dereference symlinks reflects the
      semantics of other common filesystem calls (such as those in the os
      module, or the underlying functions of the POSIX API).

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

      stdlibStandard Library Python modules in the Lib/ directorytype-crashA hard crash of the interpreter, possibly with a core dump

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions