From 256c5b099511c7b78df0e52f2e917f04c65ea643 Mon Sep 17 00:00:00 2001 From: armorbreak001 Date: Wed, 22 Apr 2026 22:25:29 +0800 Subject: [PATCH] fix: handle OSError from getpass.getuser on Python 3.13+ 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. --- aiomysql/connection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiomysql/connection.py b/aiomysql/connection.py index 046a9a95..55e88cd4 100644 --- a/aiomysql/connection.py +++ b/aiomysql/connection.py @@ -40,7 +40,7 @@ try: DEFAULT_USER = getpass.getuser() -except KeyError: +except (KeyError, OSError): DEFAULT_USER = "unknown"