From 0f78cfacce330a9f1cb2653f0a5341d13b41bc56 Mon Sep 17 00:00:00 2001 From: Cycloctane Date: Sat, 26 Jul 2025 20:00:26 +0800 Subject: [PATCH] Catch OSError in getpass --- asyncmy/connection.pyx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/asyncmy/connection.pyx b/asyncmy/connection.pyx index 3d1d7e7..c35de04 100644 --- a/asyncmy/connection.pyx +++ b/asyncmy/connection.pyx @@ -51,8 +51,10 @@ try: DEFAULT_USER = getpass.getuser() del getpass -except (ImportError, KeyError): - # KeyError occurs when there's no entry in OS database for a current user. +except (ImportError, KeyError, OSError): + # When there's no entry in OS database for a current user: + # KeyError is raised in Python 3.12 and below. + # OSError is raised in Python 3.13+ DEFAULT_USER = None cdef set TEXT_TYPES = {