Skip to content

getpass.getuser() raises OSError in Python 3.13 #130

@mkrzysiek24

Description

@mkrzysiek24

Hi,
Starting from Python 3.13, getpass.getuser() raises an OSError instead of a KeyError when the current UID doesn’t exist in /etc/passwd (i.e. when the user is anonymous or not defined in the system).

Would you mind updating the code to also catch OSError, so the error doesn’t get raised in such cases?

Here’s the relevant line:

except (ImportError, KeyError):

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions