GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Pathlib .owner() and .group() methods fail on broken links · Issue #65521 · python/cpython

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

New issue
Copy link
New issue
Copy link
Closed
Closed
Pathlib .owner() and .group() methods fail on broken links#65521
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump

Description

inigoserna
mannequin
opened on Apr 21, 2014
Issue body actions
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

      @inigoserna
      inigosernamannequin
      on Apr 21, 2014
      MannequinAuthor
      More actions

      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. inigoserna
      added
      stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
      type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
      on Apr 21, 2014
    3. pitrou commented on Apr 21, 2014

      @pitrou
      pitrou
      on Apr 21, 2014
      Member
      More actions

      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

      @inigoserna
      inigosernamannequin
      on Apr 22, 2014
      MannequinAuthor
      More actions

      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
      pitrou
      on Apr 22, 2014
      Member
      More actions
      • 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. serhiy-storchaka
      closed this as completedon Nov 9, 2017
    7. ezio-melotti
      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/ directoryStandard Library Python modules in the Lib/ directorytype-crashA hard crash of the interpreter, possibly with a core dumpA 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

        You are visitor 01402503 — GeezerVison does not store the pages you look up.
        Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.