Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • pypy pypy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 676
    • Issues 676
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 13
    • Merge requests 13
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • PyPyPyPy
  • pypypypy
  • Issues
  • #3624
Closed
Open
Issue created Dec 27, 2021 by Tom Most@twm

Passing `bytes` to `pwd.getpwnam()` raises `TypeError` on CPython

The pwd.getpwnam() function looks up a user record by username, or raises KeyError . The username is supposed to be a str, and CPython raises TypeError if you pass another type, like bytes. PyPy 3.6 and 3.7 raise KeyError in this case. Additionally, PyPy's exception message doesn't use repr() on the key, so the type issue isn't apparent in the traceback:

builtins.KeyError: 'getpwnam(): name not found: i-am-bytes'

PyPy should check the type to match CPython's behavior. Raising KeyError is a Python 2 porting hazard, since the caller will usually catch that exception and treat it as if the user record is not present.

Discovered on this Twisted PR. See this failure of this test.

Edited Dec 28, 2021 by Matti Picus
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking