From 1442e467dac208773c5e7f9429f5bdb891f3470f Mon Sep 17 00:00:00 2001 From: Jonathan Dung Date: Sat, 28 Mar 2026 12:03:32 +0800 Subject: [PATCH 1/2] See #146549 --- Lib/ctypes/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py index 7fc1181f25a264..929ebc81ff7875 100644 --- a/Lib/ctypes/__init__.py +++ b/Lib/ctypes/__init__.py @@ -18,7 +18,7 @@ from struct import calcsize as _calcsize if __version__ != _ctypes_version: - raise Exception("Version number mismatch", __version__, _ctypes_version) + raise SystemError("Version number mismatch", __version__, _ctypes_version) if _os.name == "nt": from _ctypes import FormatError From ae555ddb591848d4a3ef7e615fa4fedfbd45c1ae Mon Sep 17 00:00:00 2001 From: Jonathan Dung Date: Sat, 28 Mar 2026 13:38:37 +0800 Subject: [PATCH 2/2] Incorporate suggestion by @Shrey-N --- Lib/ctypes/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py index 929ebc81ff7875..18dfd19420bff2 100644 --- a/Lib/ctypes/__init__.py +++ b/Lib/ctypes/__init__.py @@ -18,7 +18,9 @@ from struct import calcsize as _calcsize if __version__ != _ctypes_version: - raise SystemError("Version number mismatch", __version__, _ctypes_version) + raise SystemError( + f"ctypes version mismatch: Python={__version__}, _ctypes={_ctypes_version}" + ) if _os.name == "nt": from _ctypes import FormatError