Skip to content

gh-133866: remove deprecated and undocumented function ctypes.SetPointerType #133869

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Doc/whatsnew/3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ Deprecated
Removed
=======

ctypes
------

* Removed the undocumented function :func:`!ctypes.SetPointerType`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Removed the undocumented function :func:`!ctypes.SetPointerType`.
* Removed the undocumented function :func:`!ctypes.SetPointerType`,
which has been deprecated since 3.13.

(and similar in the NEWS blurb)

(Contributed by Bénédikt Tran in :gh:`133866`.)


sysconfig
---------

Expand Down
6 changes: 0 additions & 6 deletions Lib/ctypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 3 additions & 6 deletions Lib/test/test_ctypes/test_incomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ class cell(Structure):
_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)

Expand All @@ -50,10 +48,9 @@ class cell(Structure):
_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()
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Remove the undocumented function :func:`!ctypes.SetPointerType`.
Patch by Bénédikt Tran.
Loading