From 6aa52cdffaafcc0006b07da424dc8d9944ec81b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 11 May 2025 09:59:24 +0200 Subject: [PATCH 1/6] remove --- Lib/ctypes/__init__.py | 6 ------ Lib/test/test_ctypes/test_incomplete.py | 9 +++------ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py index 823a3692fd1bbf..d6d07a13f756e2 100644 --- a/Lib/ctypes/__init__.py +++ b/Lib/ctypes/__init__.py @@ -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 diff --git a/Lib/test/test_ctypes/test_incomplete.py b/Lib/test/test_ctypes/test_incomplete.py index fefdfe9102e668..2f344611995b2c 100644 --- a/Lib/test/test_ctypes/test_incomplete.py +++ b/Lib/test/test_ctypes/test_incomplete.py @@ -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) @@ -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() From f5b3ec0ad3f3295ec746ad30ecfd0dfc72eafdaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 11 May 2025 10:01:22 +0200 Subject: [PATCH 2/6] remove `ctypes.SetPointerType` --- Doc/whatsnew/3.15.rst | 8 ++++++++ .../2025-05-11-10-01-48.gh-issue-133866.g3dHP_.rst | 2 ++ 2 files changed, 10 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2025-05-11-10-01-48.gh-issue-133866.g3dHP_.rst diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 8e5a6fe9efaeff..8ad3178e44178e 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -121,6 +121,14 @@ Deprecated Removed ======= +ctypes +------ + +* The undocumented function :func:`!ctypes.SetPointerType`. + Use ``ptr.set_type(cls)`` instead. + (Contributed by Bénédikt Tran in :gh:`133866`.) + + typing ------ 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 index 00000000000000..b956978920fd8e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-05-11-10-01-48.gh-issue-133866.g3dHP_.rst @@ -0,0 +1,2 @@ +The undocumented function :func:`!ctypes.SetPointerType`. Use +``ptr.set_type(cls)`` instead. Patch by Bénédikt Tran. From 89ed00aa2ef17a93866b0d0cb7eade504c7a797a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 11 May 2025 10:08:04 +0200 Subject: [PATCH 3/6] update NEWS --- Doc/whatsnew/3.15.rst | 1 - .../Library/2025-05-11-10-01-48.gh-issue-133866.g3dHP_.rst | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 8ad3178e44178e..6ab894a6488357 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -125,7 +125,6 @@ ctypes ------ * The undocumented function :func:`!ctypes.SetPointerType`. - Use ``ptr.set_type(cls)`` instead. (Contributed by Bénédikt Tran in :gh:`133866`.) 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 index b956978920fd8e..bf3327224db24f 100644 --- 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 @@ -1,2 +1,2 @@ -The undocumented function :func:`!ctypes.SetPointerType`. Use -``ptr.set_type(cls)`` instead. Patch by Bénédikt Tran. +Remove the undocumented function :func:`!ctypes.SetPointerType`. +Patch by Bénédikt Tran. From a4c670080e2f54dd782b696fe2f60784e4399cb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 11 May 2025 11:19:02 +0200 Subject: [PATCH 4/6] Update Doc/whatsnew/3.15.rst --- Doc/whatsnew/3.15.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 6f2761548255fd..d8dbbd5dde6c6f 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -124,7 +124,7 @@ Removed ctypes ------ -* The undocumented function :func:`!ctypes.SetPointerType`. +* Removed the undocumented function :func:`!ctypes.SetPointerType`. (Contributed by Bénédikt Tran in :gh:`133866`.) From 0f7ecfe8c3557d58af1acf684fb5033ec0a46d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Thu, 15 May 2025 16:16:04 +0200 Subject: [PATCH 5/6] Apply suggestions from code review Co-authored-by: Petr Viktorin --- Doc/whatsnew/3.15.rst | 3 ++- .../Library/2025-05-11-10-01-48.gh-issue-133866.g3dHP_.rst | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 8d8c1bd0dfe8ee..76c3683cb3a894 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -124,7 +124,8 @@ Removed ctypes ------ -* Removed the undocumented function :func:`!ctypes.SetPointerType`. +* Removed the undocumented function :func:`!ctypes.SetPointerType`, + which has been deprecated since 3.13. (Contributed by Bénédikt Tran in :gh:`133866`.) 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 index bf3327224db24f..15ec25b821c4c4 100644 --- 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 @@ -1,2 +1,3 @@ -Remove the undocumented function :func:`!ctypes.SetPointerType`. +Remove the undocumented function :func:`!ctypes.SetPointerType`, +which has been deprecated since 3.13. Patch by Bénédikt Tran. From 270bc1c3ba02cf42b4eb66a81be9eb111850b99c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Fri, 16 May 2025 13:29:40 +0200 Subject: [PATCH 6/6] Apply suggestions from code review --- Doc/whatsnew/3.15.rst | 2 +- .../next/Library/2025-05-11-10-01-48.gh-issue-133866.g3dHP_.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 76c3683cb3a894..bc00dc0d672b6c 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -125,7 +125,7 @@ ctypes ------ * Removed the undocumented function :func:`!ctypes.SetPointerType`, - which has been deprecated since 3.13. + which has been deprecated since Python 3.13. (Contributed by Bénédikt Tran in :gh:`133866`.) 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 index 15ec25b821c4c4..00f13c9a305eb5 100644 --- 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 @@ -1,3 +1,3 @@ Remove the undocumented function :func:`!ctypes.SetPointerType`, -which has been deprecated since 3.13. +which has been deprecated since Python 3.13. Patch by Bénédikt Tran.