Skip to content

Commit cafbcd6

Browse files
authored
gh-133866: remove deprecated and undocumented function ctypes.SetPointerType (GH-133869)
1 parent b783e17 commit cafbcd6

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

Doc/whatsnew/3.15.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,14 @@ Deprecated
138138
Removed
139139
=======
140140

141+
ctypes
142+
------
143+
144+
* Removed the undocumented function :func:`!ctypes.SetPointerType`,
145+
which has been deprecated since Python 3.13.
146+
(Contributed by Bénédikt Tran in :gh:`133866`.)
147+
148+
141149
http.server
142150
-----------
143151

Lib/ctypes/__init__.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,6 @@ def create_unicode_buffer(init, size=None):
379379
return buf
380380
raise TypeError(init)
381381

382-
383-
def SetPointerType(pointer, cls):
384-
import warnings
385-
warnings._deprecated("ctypes.SetPointerType", remove=(3, 15))
386-
pointer.set_type(cls)
387-
388382
def ARRAY(typ, len):
389383
return typ * len
390384

Lib/test/test_ctypes/test_incomplete.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ class cell(Structure):
2121
_fields_ = [("name", c_char_p),
2222
("next", lpcell)]
2323

24-
with warnings.catch_warnings():
25-
warnings.simplefilter('ignore', DeprecationWarning)
26-
ctypes.SetPointerType(lpcell, cell)
24+
lpcell.set_type(cell)
2725

2826
self.assertIs(POINTER(cell), lpcell)
2927

@@ -50,10 +48,9 @@ class cell(Structure):
5048
_fields_ = [("name", c_char_p),
5149
("next", lpcell)]
5250

53-
with self.assertWarns(DeprecationWarning):
54-
ctypes.SetPointerType(lpcell, cell)
55-
51+
lpcell.set_type(cell)
5652
self.assertIs(POINTER(cell), lpcell)
5753

54+
5855
if __name__ == '__main__':
5956
unittest.main()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Remove the undocumented function :func:`!ctypes.SetPointerType`,
2+
which has been deprecated since Python 3.13.
3+
Patch by Bénédikt Tran.

0 commit comments

Comments
 (0)