-
Notifications
You must be signed in to change notification settings - Fork 266
Open
Labels
Description
Describe the bug
As of Python 3.13, getpass.getuser now raises OSError on any failures instead of KeyError. This means that this line doesn't work anymore, and the library crashes on import.
PyMySQL fixed this issue in this commit: PyMySQL/PyMySQL@a1ac823
To Reproduce
- Import aiomysql inside a Docker container with Python 3.13+ with the UID set to something without a username.
- Observe crash.
Expected behavior
It does not crash.
Logs/tracebacks
Traceback (most recent call last):
File "/usr/local/lib/python3.13/getpass.py", line 173, in getuser
return pwd.getpwuid(os.getuid())[0]
~~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'getpwuid(): uid not found: 8459'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/app/lib/python3.13/site-packages/package/__main__.py", line 1, in <module>
from package import main
File "/app/lib/python3.13/site-packages/package/esc_dl.py", line 17, in <module>
import aiomysql
File "/app/lib/python3.13/site-packages/aiomysql/__init__.py", line 32, in <module>
from .connection import Connection, connect
File "/app/lib/python3.13/site-packages/aiomysql/connection.py", line 42, in <module>
DEFAULT_USER = getpass.getuser()
File "/usr/local/lib/python3.13/getpass.py", line 175, in getuser
raise OSError('No username set in the environment') from e
OSError: No username set in the environmentPython Version
$ python --version
Python 3.13.9aiomysql Version
$ python -m pip show aiomysql
Name: aiomysql
Version: 0.3.2
Location: /package/.venv/lib/python3.13/site-packages
Requires: pymysql
Required-by: ...PyMySQL Version
$ python -m pip show PyMySQL
Name: pymysql
Version: 1.1.2
Location: /package/.venv/lib/python3.13/site-packages
Requires:
Required-by: aiomysqlSQLAlchemy Version
$ python -m pip show sqlalchemy
N/AOS
Linux 6.8.0-84-generic #84-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 5 22:36:38 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Database type and version
SELECT VERSION();
N/AAdditional context
No response
Code of Conduct
- I agree to follow the aio-libs Code of Conduct