From 26c74d8b2a59c84affcdfb32b8197e068c2338eb Mon Sep 17 00:00:00 2001
From: Cody Maloney
Date: Wed, 25 Nov 2026 15:54:20 -0800
Subject: [PATCH] gh-162350: Add a signature to pickle.PickleBuffer
Name the Argument Clinic parameter `buffer` to match the documented
`PickleBuffer(buffer)` and move the type docstring into the clinic block,
so `inspect.signature(pickle.PickleBuffer)` gives `(buffer, /)`.
Co-Authored-By: Claude Opus 5.5
---
Objects/clinic/picklebufobject.c.h | 8 +++++++-
Objects/picklebufobject.c | 8 +++++---
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/Objects/clinic/picklebufobject.c.h b/Objects/clinic/picklebufobject.c.h
index 8f09b465a2350c6..e694942191a0fef 100644
--- a/Objects/clinic/picklebufobject.c.h
+++ b/Objects/clinic/picklebufobject.c.h
@@ -4,6 +4,12 @@ preserve
#include "pycore_modsupport.h" // _PyArg_CheckPositional()
+PyDoc_STRVAR(picklebuf_new__doc__,
+"PickleBuffer(buffer, /)\n"
+"--\n"
+"\n"
+"Wrapper for potentially out-of-band buffers.");
+
static PyObject *
picklebuf_new_impl(PyTypeObject *type, PyObject *base);
@@ -52,4 +58,4 @@ picklebuf_vectorcall(PyObject *type, PyObject *const *args,
exit:
return return_value;
}
-/*[clinic end generated code: output=dcacd3b2ee177774 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=4c32a9c4ea5b9bfe input=a9049054013a1b77]*/
diff --git a/Objects/picklebufobject.c b/Objects/picklebufobject.c
index 4ab0f528b8e65ed..18cfe9f9f645943 100644
--- a/Objects/picklebufobject.c
+++ b/Objects/picklebufobject.c
@@ -83,13 +83,15 @@ PyPickleBuffer_Release(PyObject *obj)
@classmethod
pickle.PickleBuffer.__new__ as picklebuf_new
- base: object
+ buffer as base: object
/
+
+Wrapper for potentially out-of-band buffers.
[clinic start generated code]*/
static PyObject *
picklebuf_new_impl(PyTypeObject *type, PyObject *base)
-/*[clinic end generated code: output=b8269110aace6998 input=0f1cdf375a70e71d]*/
+/*[clinic end generated code: output=b8269110aace6998 input=616fff5fc36c22d4]*/
{
PyPickleBufferObject *self = (PyPickleBufferObject *) type->tp_alloc(type, 0);
if (self == NULL) {
@@ -224,7 +226,7 @@ static PyMethodDef picklebuf_methods[] = {
PyTypeObject PyPickleBuffer_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "pickle.PickleBuffer",
- .tp_doc = PyDoc_STR("Wrapper for potentially out-of-band buffers"),
+ .tp_doc = picklebuf_new__doc__,
.tp_basicsize = sizeof(PyPickleBufferObject),
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
.tp_new = picklebuf_new,