[Python-checkins] gh-104955: Fix __release_buffer__ signature (#104956)
JelleZijlstra
webhook-mailer at python.org
Fri May 26 08:44:31 EDT 2023
https://github.com/python/cpython/commit/6e1eccdcce5ea3bf1ef9d326d20ef9df21262c6b
commit: 6e1eccdcce5ea3bf1ef9d326d20ef9df21262c6b
branch: main
author: Jelle Zijlstra <jelle.zijlstra at gmail.com>
committer: JelleZijlstra <jelle.zijlstra at gmail.com>
date: 2023-05-26T05:44:23-07:00
summary:
gh-104955: Fix __release_buffer__ signature (#104956)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303 at users.noreply.github.com>
files:
A Misc/NEWS.d/next/Core and Builtins/2023-05-25-21-40-39.gh-issue-104955.LZx7jf.rst
M Lib/test/test_inspect.py
M Objects/typeobject.c
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 0590e49d0e1a..ade32151eaf2 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 000000000000..9fccf2a41ffb
--- /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:`~object.__release_buffer__` slot. Patch by Jelle
+Zijlstra.
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 2fbcafe91aad..0a2e1b1d3c1f 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,
More information about the Python-checkins
mailing list