From 74617c78f7986bba7d0b4b02393a16fcb8c08ec4 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 25 May 2023 21:48:23 -0700 Subject: [PATCH 1/2] gh-104955: Fix __release_buffer__ signature --- Lib/test/test_inspect.py | 5 +++++ .../2023-05-25-21-40-39.gh-issue-104955.LZx7jf.rst | 2 ++ Objects/typeobject.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2023-05-25-21-40-39.gh-issue-104955.LZx7jf.rst diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py index 0590e49d0e1a43..ade32151eaf233 100644 --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -2766,6 +2766,11 @@ class ThisWorksNow: # Regression test for issue #20586 test_callable(_testcapi.docstring_with_signature_but_no_doc) + # Regression test for gh-104955 + method = bytearray.__release_buffer__ + sig = test_unbound_method(method) + self.assertEqual(list(sig.parameters), ['self', 'buffer']) + @cpython_only @unittest.skipIf(MISSING_C_DOCSTRINGS, "Signature information for builtins requires docstrings") diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-05-25-21-40-39.gh-issue-104955.LZx7jf.rst b/Misc/NEWS.d/next/Core and Builtins/2023-05-25-21-40-39.gh-issue-104955.LZx7jf.rst new file mode 100644 index 00000000000000..5f234ae8795c3b --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2023-05-25-21-40-39.gh-issue-104955.LZx7jf.rst @@ -0,0 +1,2 @@ +Fix signature for the new :meth:`__release_buffer__` slot. Patch by Jelle +Zijlstra. diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 2fbcafe91aadc6..0a2e1b1d3c1f78 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -9428,7 +9428,7 @@ static pytype_slotdef slotdefs[] = { "__buffer__($self, flags, /)\n--\n\n" "Return a buffer object that exposes the underlying memory of the object."), BUFSLOT(__release_buffer__, bf_releasebuffer, slot_bf_releasebuffer, wrap_releasebuffer, - "__release_buffer__($self, /)\n--\n\n" + "__release_buffer__($self, buffer, /)\n--\n\n" "Release the buffer object that exposes the underlying memory of the object."), AMSLOT(__await__, am_await, slot_am_await, wrap_unaryfunc, From 3c5d2cf5078bb0c2363fe0fcf979b70efe7683a2 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 25 May 2023 22:15:31 -0700 Subject: [PATCH 2/2] Update Misc/NEWS.d/next/Core and Builtins/2023-05-25-21-40-39.gh-issue-104955.LZx7jf.rst Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> --- .../2023-05-25-21-40-39.gh-issue-104955.LZx7jf.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-05-25-21-40-39.gh-issue-104955.LZx7jf.rst b/Misc/NEWS.d/next/Core and Builtins/2023-05-25-21-40-39.gh-issue-104955.LZx7jf.rst index 5f234ae8795c3b..9fccf2a41ffb6f 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2023-05-25-21-40-39.gh-issue-104955.LZx7jf.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2023-05-25-21-40-39.gh-issue-104955.LZx7jf.rst @@ -1,2 +1,2 @@ -Fix signature for the new :meth:`__release_buffer__` slot. Patch by Jelle +Fix signature for the new :meth:`~object.__release_buffer__` slot. Patch by Jelle Zijlstra.