Skip to content

fix: handle OSError from getpass.getuser on Python 3.13+#1074

Open
armorbreak001 wants to merge 1 commit intoaio-libs:mainfrom
armorbreak001:fix/getuser-python313
Open

fix: handle OSError from getpass.getuser on Python 3.13+#1074
armorbreak001 wants to merge 1 commit intoaio-libs:mainfrom
armorbreak001:fix/getuser-python313

Conversation

@armorbreak001
Copy link
Copy Markdown

Summary

Python 3.13 changed getpass.getuser() to raise OSError instead of KeyError when the UID has no matching username entry (e.g. in containers with numeric UIDs, see bpo-32731). The current code only catches KeyError, so importing aiomysql crashes on Python 3.13+ in such environments.

This mirrors the fix applied to PyMySQL in PyMySQL/PyMySQL@a1ac823.

Details

Before: Import fails with OSError on Python 3.13+ when UID is unmapped
After: Gracefully falls back to "unknown" user, same as the existing KeyError path

Fixes #1053

Python 3.13 changed getpass.getuser() to raise OSError instead
of KeyError when the UID has no matching username entry (e.g.
in containers with numeric UIDs). Catch both for compatibility.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Importing fails with OSError from getpass.getuser on Python 3.13+

1 participant