Skip to content

Commit d5c7809

Browse files
committed
pythongh-111178: Change Argument Clinic signature for @staticmethod (python#131157)
Use "PyObject*", instead of "void*", for `@staticmethod` functions to fix an undefined behavior.
1 parent 061da44 commit d5c7809

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

Lib/test/clinic.test.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -5262,14 +5262,14 @@ static PyObject *
52625262
Test_static_method_impl();
52635263

52645264
static PyObject *
5265-
Test_static_method(void *null, PyObject *Py_UNUSED(ignored))
5265+
Test_static_method(PyObject *null, PyObject *Py_UNUSED(ignored))
52665266
{
52675267
return Test_static_method_impl();
52685268
}
52695269

52705270
static PyObject *
52715271
Test_static_method_impl()
5272-
/*[clinic end generated code: output=82524a63025cf7ab input=dae892fac55ae72b]*/
5272+
/*[clinic end generated code: output=9e401fb6ed56a4f3 input=dae892fac55ae72b]*/
52735273

52745274

52755275
/*[clinic input]

Objects/clinic/bytearrayobject.c.h

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Objects/clinic/bytesobject.c.h

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Objects/clinic/unicodeobject.c.h

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tools/clinic/libclinic/converters.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,10 @@ def correct_name_for_self(
11151115
return "PyObject *", "self"
11161116
return "PyObject *", "module"
11171117
if f.kind is STATIC_METHOD:
1118-
return "void *", "null"
1118+
if parser:
1119+
return "PyObject *", "null"
1120+
else:
1121+
return "void *", "null"
11191122
if f.kind == CLASS_METHOD:
11201123
if parser:
11211124
return "PyObject *", "type"

0 commit comments

Comments
 (0)