https://github.com/python/cpython/commit/c81693b92699cdc553ba63337609b4bc7f81d224
commit: c81693b92699cdc553ba63337609b4bc7f81d224
branch: main
author: Peter Bierma <[email protected]>
committer: ZeroIntensity <[email protected]>
date: 2026-09-19T15:01:01Z
summary:

gh-157763: Soft-deprecate `ctypes.util.test` (GH-157776)

files:
A Misc/NEWS.d/next/Library/2026-09-18-17-33-31.gh-issue-157763.Wd0_Uo.rst
M Lib/ctypes/util.py

diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
index 2b01506f3d4ffab..f4fb05c29b4ca45 100644
--- a/Lib/ctypes/util.py
+++ b/Lib/ctypes/util.py
@@ -416,7 +416,7 @@ def find_library(name):
 # On platforms which provide dl_iterate_phdr(), dllist() is implemented
 # in _ctypes.
 try:
-    from _ctypes import dllist
+    from _ctypes import dllist as dllist
 except ImportError:
     pass
 
@@ -525,55 +525,8 @@ def decorator(func):
 
     return decorator
 
-################################################################
-# test code
-
 def test():
-    from ctypes import cdll
-    if os.name == "nt":
-        print(cdll.msvcrt)
-        print(cdll.load("msvcrt"))
-        print(find_library("msvcrt"))
-
-    if os.name == "posix":
-        # find and load_version
-        print(find_library("m"))
-        print(find_library("c"))
-        print(find_library("bz2"))
-
-        # load
-        if sys.platform == "darwin":
-            print(cdll.LoadLibrary("libm.dylib"))
-            print(cdll.LoadLibrary("libcrypto.dylib"))
-            print(cdll.LoadLibrary("libSystem.dylib"))
-            print(cdll.LoadLibrary("System.framework/System"))
-        # issue-26439 - fix broken test call for AIX
-        elif sys.platform.startswith("aix"):
-            from ctypes import CDLL
-            if sys.maxsize < 2**32:
-                print(f"Using CDLL(name, os.RTLD_MEMBER): 
{CDLL('libc.a(shr.o)', os.RTLD_MEMBER)}")
-                print(f"Using cdll.LoadLibrary(): 
{cdll.LoadLibrary('libc.a(shr.o)')}")
-                # librpm.so is only available as 32-bit shared library
-                print(find_library("rpm"))
-                print(cdll.LoadLibrary("librpm.so"))
-            else:
-                print(f"Using CDLL(name, os.RTLD_MEMBER): 
{CDLL('libc.a(shr_64.o)', os.RTLD_MEMBER)}")
-                print(f"Using cdll.LoadLibrary(): 
{cdll.LoadLibrary('libc.a(shr_64.o)')}")
-            print(f"crypt\t:: {find_library('crypt')}")
-            print(f"crypt\t:: {cdll.LoadLibrary(find_library('crypt'))}")
-            print(f"crypto\t:: {find_library('crypto')}")
-            print(f"crypto\t:: {cdll.LoadLibrary(find_library('crypto'))}")
-        else:
-            print(cdll.LoadLibrary("libm.so"))
-            print(cdll.LoadLibrary("libcrypt.so"))
-            print(find_library("crypt"))
-
-    try:
-        dllist
-    except NameError:
-        print('dllist() not available')
-    else:
-        print(dllist())
-
-if __name__ == "__main__":
-    test()
+    """
+    This function is a no-op and is soft-deprecated since Python 3.16.
+    Do not use.
+    """
diff --git 
a/Misc/NEWS.d/next/Library/2026-09-18-17-33-31.gh-issue-157763.Wd0_Uo.rst 
b/Misc/NEWS.d/next/Library/2026-09-18-17-33-31.gh-issue-157763.Wd0_Uo.rst
new file mode 100644
index 000000000000000..712fe6310579b14
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2026-09-18-17-33-31.gh-issue-157763.Wd0_Uo.rst
@@ -0,0 +1,2 @@
+The undocumented :func:`!ctypes.util.test` function is now :term:`soft
+deprecated` and a no-op at runtime.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to