]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-104955: Fix __release_buffer__ signature (#104956)
authorJelle Zijlstra <jelle.zijlstra@gmail.com>
Fri, 26 May 2023 12:44:23 +0000 (05:44 -0700)
committerGitHub <noreply@github.com>
Fri, 26 May 2023 12:44:23 +0000 (05:44 -0700)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Lib/test/test_inspect.py
Misc/NEWS.d/next/Core and Builtins/2023-05-25-21-40-39.gh-issue-104955.LZx7jf.rst [new file with mode: 0644]
Objects/typeobject.c

index 0590e49d0e1a431f808cd0431619617e25ca9dc3..ade32151eaf2339ffea11a6c4dfe2dc24a5d7c63 100644 (file)
@@ -2766,6 +2766,11 @@ class TestSignatureObject(unittest.TestCase):
         # 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 (file)
index 0000000..9fccf2a
--- /dev/null
@@ -0,0 +1,2 @@
+Fix signature for the new :meth:`~object.__release_buffer__` slot. Patch by Jelle
+Zijlstra.
index 2fbcafe91aadc6355d58b6d34c4bdc4803f781a6..0a2e1b1d3c1f7819f9bb1ce1e1d1062c028506ca 100644 (file)
@@ -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,