gh-104955: Fix __release_buffer__ signature (#104956)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
This commit is contained in:
Jelle Zijlstra 2023-05-26 05:44:23 -07:00 committed by GitHub
parent 6c81d7572e
commit 6e1eccdcce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

View File

@ -2766,6 +2766,11 @@ class TestSignatureObject(unittest.TestCase):
# Regression test for issue #20586 # Regression test for issue #20586
test_callable(_testcapi.docstring_with_signature_but_no_doc) 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 @cpython_only
@unittest.skipIf(MISSING_C_DOCSTRINGS, @unittest.skipIf(MISSING_C_DOCSTRINGS,
"Signature information for builtins requires docstrings") "Signature information for builtins requires docstrings")

View File

@ -0,0 +1,2 @@
Fix signature for the new :meth:`~object.__release_buffer__` slot. Patch by Jelle
Zijlstra.

View File

@ -9428,7 +9428,7 @@ static pytype_slotdef slotdefs[] = {
"__buffer__($self, flags, /)\n--\n\n" "__buffer__($self, flags, /)\n--\n\n"
"Return a buffer object that exposes the underlying memory of the object."), "Return a buffer object that exposes the underlying memory of the object."),
BUFSLOT(__release_buffer__, bf_releasebuffer, slot_bf_releasebuffer, wrap_releasebuffer, 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."), "Release the buffer object that exposes the underlying memory of the object."),
AMSLOT(__await__, am_await, slot_am_await, wrap_unaryfunc, AMSLOT(__await__, am_await, slot_am_await, wrap_unaryfunc,