Skip to content

Commit 061da44

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

22 files changed

+164
-62
lines changed

Lib/test/clinic.test.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -5235,14 +5235,14 @@ static PyObject *
52355235
Test_class_method_impl(PyTypeObject *type);
52365236

52375237
static PyObject *
5238-
Test_class_method(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
5238+
Test_class_method(PyObject *type, PyObject *Py_UNUSED(ignored))
52395239
{
5240-
return Test_class_method_impl(type);
5240+
return Test_class_method_impl((PyTypeObject *)type);
52415241
}
52425242

52435243
static PyObject *
52445244
Test_class_method_impl(PyTypeObject *type)
5245-
/*[clinic end generated code: output=47fb7ecca1abcaaa input=43bc4a0494547b80]*/
5245+
/*[clinic end generated code: output=64f93e6252bde409 input=43bc4a0494547b80]*/
52465246

52475247

52485248
/*[clinic input]

Modules/_datetimemodule.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3290,8 +3290,8 @@ as local time.
32903290
[clinic start generated code]*/
32913291

32923292
static PyObject *
3293-
datetime_date_fromtimestamp(PyTypeObject *type, PyObject *timestamp)
3294-
/*[clinic end generated code: output=fd045fda58168869 input=eabb3fe7f40491fe]*/
3293+
datetime_date_fromtimestamp_impl(PyTypeObject *type, PyObject *timestamp)
3294+
/*[clinic end generated code: output=59def4e32c028fb6 input=eabb3fe7f40491fe]*/
32953295
{
32963296
return date_fromtimestamp((PyObject *) type, timestamp);
32973297
}

Modules/_multiprocessing/clinic/semaphore.c.h

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

Modules/clinic/_datetimemodule.c.h

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

Modules/clinic/_zoneinfo.c.h

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

Modules/clinic/itertoolsmodule.c.h

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

Modules/clinic/selectmodule.c.h

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

Modules/itertoolsmodule.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1843,8 +1843,8 @@ Alternative chain() constructor taking a single iterable argument that evaluates
18431843
[clinic start generated code]*/
18441844

18451845
static PyObject *
1846-
itertools_chain_from_iterable(PyTypeObject *type, PyObject *arg)
1847-
/*[clinic end generated code: output=667ae7a7f7b68654 input=72c39e3a2ca3be85]*/
1846+
itertools_chain_from_iterable_impl(PyTypeObject *type, PyObject *arg)
1847+
/*[clinic end generated code: output=3d7ea7d46b9e43f5 input=72c39e3a2ca3be85]*/
18481848
{
18491849
PyObject *source;
18501850

Objects/bytearrayobject.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2543,8 +2543,8 @@ Example: bytearray.fromhex('B9 01EF') -> bytearray(b'\\xb9\\x01\\xef')
25432543
[clinic start generated code]*/
25442544

25452545
static PyObject *
2546-
bytearray_fromhex(PyTypeObject *type, PyObject *string)
2547-
/*[clinic end generated code: output=da84dc708e9c4b36 input=7e314e5b2d7ab484]*/
2546+
bytearray_fromhex_impl(PyTypeObject *type, PyObject *string)
2547+
/*[clinic end generated code: output=8f0f0b6d30fb3ba0 input=7e314e5b2d7ab484]*/
25482548
{
25492549
PyObject *result = _PyBytes_FromHex(string, type == &PyByteArray_Type);
25502550
if (type != &PyByteArray_Type && result != NULL) {

Objects/bytesobject.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2494,8 +2494,8 @@ Example: bytes.fromhex('B9 01EF') -> b'\\xb9\\x01\\xef'.
24942494
[clinic start generated code]*/
24952495

24962496
static PyObject *
2497-
bytes_fromhex(PyTypeObject *type, PyObject *string)
2498-
/*[clinic end generated code: output=d458ec88195da6b3 input=f37d98ed51088a21]*/
2497+
bytes_fromhex_impl(PyTypeObject *type, PyObject *string)
2498+
/*[clinic end generated code: output=0973acc63661bb2e input=f37d98ed51088a21]*/
24992499
{
25002500
PyObject *result = _PyBytes_FromHex(string, 0);
25012501
if (type != &PyBytes_Type && result != NULL) {

Objects/clinic/bytearrayobject.c.h

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

Objects/clinic/bytesobject.c.h

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

Objects/clinic/complexobject.c.h

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

Objects/clinic/dictobject.c.h

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

0 commit comments

Comments
 (0)