]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-133866: remove deprecated and undocumented function `ctypes.SetPointerType` (GH...
authorBénédikt Tran <10796600+picnixz@users.noreply.github.com>
Thu, 29 May 2025 13:28:57 +0000 (15:28 +0200)
committerGitHub <noreply@github.com>
Thu, 29 May 2025 13:28:57 +0000 (15:28 +0200)
Doc/whatsnew/3.15.rst
Lib/ctypes/__init__.py
Lib/test/test_ctypes/test_incomplete.py
Misc/NEWS.d/next/Library/2025-05-11-10-01-48.gh-issue-133866.g3dHP_.rst [new file with mode: 0644]

index 87cca4eeff385a8c4b81dcaa055936c1cc638bdf..ced9c63071a53c97465b3ff48f0c76f8d05df077 100644 (file)
@@ -138,6 +138,14 @@ Deprecated
 Removed
 =======
 
+ctypes
+------
+
+* Removed the undocumented function :func:`!ctypes.SetPointerType`,
+  which has been deprecated since Python 3.13.
+  (Contributed by Bénédikt Tran in :gh:`133866`.)
+
+
 http.server
 -----------
 
index 823a3692fd1bbf9cdc0b60f025f3707132d59c3f..d6d07a13f756e2c6918aa3803c11653a89388c31 100644 (file)
@@ -379,12 +379,6 @@ def create_unicode_buffer(init, size=None):
         return buf
     raise TypeError(init)
 
-
-def SetPointerType(pointer, cls):
-    import warnings
-    warnings._deprecated("ctypes.SetPointerType", remove=(3, 15))
-    pointer.set_type(cls)
-
 def ARRAY(typ, len):
     return typ * len
 
index fefdfe9102e6680b3cf198c6951cc618b8b1c9f5..2f344611995b2cbb7d04835a7e38896a6f233ccd 100644 (file)
@@ -21,9 +21,7 @@ class TestSetPointerType(unittest.TestCase):
             _fields_ = [("name", c_char_p),
                         ("next", lpcell)]
 
-        with warnings.catch_warnings():
-            warnings.simplefilter('ignore', DeprecationWarning)
-            ctypes.SetPointerType(lpcell, cell)
+        lpcell.set_type(cell)
 
         self.assertIs(POINTER(cell), lpcell)
 
@@ -50,10 +48,9 @@ class TestSetPointerType(unittest.TestCase):
             _fields_ = [("name", c_char_p),
                         ("next", lpcell)]
 
-        with self.assertWarns(DeprecationWarning):
-            ctypes.SetPointerType(lpcell, cell)
-
+        lpcell.set_type(cell)
         self.assertIs(POINTER(cell), lpcell)
 
+
 if __name__ == '__main__':
     unittest.main()
diff --git a/Misc/NEWS.d/next/Library/2025-05-11-10-01-48.gh-issue-133866.g3dHP_.rst b/Misc/NEWS.d/next/Library/2025-05-11-10-01-48.gh-issue-133866.g3dHP_.rst
new file mode 100644 (file)
index 0000000..00f13c9
--- /dev/null
@@ -0,0 +1,3 @@
+Remove the undocumented function :func:`!ctypes.SetPointerType`,
+which has been deprecated since Python 3.13.
+Patch by Bénédikt Tran.