gh-111178: Change Argument Clinic signature for @classmethod
(#131157)
Use "PyObject*", instead of "PyTypeObject*", for `@classmethod` functions to fix an undefined behavior.
This commit is contained in:
parent
de2f7da77d
commit
061da44bac
@ -5235,14 +5235,14 @@ static PyObject *
|
||||
Test_class_method_impl(PyTypeObject *type);
|
||||
|
||||
static PyObject *
|
||||
Test_class_method(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
|
||||
Test_class_method(PyObject *type, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
return Test_class_method_impl(type);
|
||||
return Test_class_method_impl((PyTypeObject *)type);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
Test_class_method_impl(PyTypeObject *type)
|
||||
/*[clinic end generated code: output=47fb7ecca1abcaaa input=43bc4a0494547b80]*/
|
||||
/*[clinic end generated code: output=64f93e6252bde409 input=43bc4a0494547b80]*/
|
||||
|
||||
|
||||
/*[clinic input]
|
||||
|
@ -3290,8 +3290,8 @@ as local time.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
datetime_date_fromtimestamp(PyTypeObject *type, PyObject *timestamp)
|
||||
/*[clinic end generated code: output=fd045fda58168869 input=eabb3fe7f40491fe]*/
|
||||
datetime_date_fromtimestamp_impl(PyTypeObject *type, PyObject *timestamp)
|
||||
/*[clinic end generated code: output=59def4e32c028fb6 input=eabb3fe7f40491fe]*/
|
||||
{
|
||||
return date_fromtimestamp((PyObject *) type, timestamp);
|
||||
}
|
||||
|
6
Modules/_multiprocessing/clinic/semaphore.c.h
generated
6
Modules/_multiprocessing/clinic/semaphore.c.h
generated
@ -323,7 +323,7 @@ _multiprocessing_SemLock__rebuild_impl(PyTypeObject *type, SEM_HANDLE handle,
|
||||
const char *name);
|
||||
|
||||
static PyObject *
|
||||
_multiprocessing_SemLock__rebuild(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs)
|
||||
_multiprocessing_SemLock__rebuild(PyObject *type, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
SEM_HANDLE handle;
|
||||
@ -335,7 +335,7 @@ _multiprocessing_SemLock__rebuild(PyTypeObject *type, PyObject *const *args, Py_
|
||||
&handle, &kind, &maxvalue, &name)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _multiprocessing_SemLock__rebuild_impl(type, handle, kind, maxvalue, name);
|
||||
return_value = _multiprocessing_SemLock__rebuild_impl((PyTypeObject *)type, handle, kind, maxvalue, name);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
@ -576,4 +576,4 @@ exit:
|
||||
#ifndef _MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF
|
||||
#define _MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF
|
||||
#endif /* !defined(_MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF) */
|
||||
/*[clinic end generated code: output=e28d0fdbfefd1235 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=dddd8e989525f565 input=a9049054013a1b77]*/
|
||||
|
19
Modules/clinic/_datetimemodule.c.h
generated
19
Modules/clinic/_datetimemodule.c.h
generated
@ -20,6 +20,19 @@ PyDoc_STRVAR(datetime_date_fromtimestamp__doc__,
|
||||
#define DATETIME_DATE_FROMTIMESTAMP_METHODDEF \
|
||||
{"fromtimestamp", (PyCFunction)datetime_date_fromtimestamp, METH_O|METH_CLASS, datetime_date_fromtimestamp__doc__},
|
||||
|
||||
static PyObject *
|
||||
datetime_date_fromtimestamp_impl(PyTypeObject *type, PyObject *timestamp);
|
||||
|
||||
static PyObject *
|
||||
datetime_date_fromtimestamp(PyObject *type, PyObject *timestamp)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
|
||||
return_value = datetime_date_fromtimestamp_impl((PyTypeObject *)type, timestamp);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
iso_calendar_date_new_impl(PyTypeObject *type, int year, int week,
|
||||
int weekday);
|
||||
@ -304,7 +317,7 @@ static PyObject *
|
||||
datetime_datetime_now_impl(PyTypeObject *type, PyObject *tz);
|
||||
|
||||
static PyObject *
|
||||
datetime_datetime_now(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
datetime_datetime_now(PyObject *type, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
||||
@ -346,7 +359,7 @@ datetime_datetime_now(PyTypeObject *type, PyObject *const *args, Py_ssize_t narg
|
||||
}
|
||||
tz = args[0];
|
||||
skip_optional_pos:
|
||||
return_value = datetime_datetime_now_impl(type, tz);
|
||||
return_value = datetime_datetime_now_impl((PyTypeObject *)type, tz);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
@ -501,4 +514,4 @@ skip_optional_kwonly:
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=8acf62fbc7328f79 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=7b55f2d9a4596b58 input=a9049054013a1b77]*/
|
||||
|
18
Modules/clinic/_zoneinfo.c.h
generated
18
Modules/clinic/_zoneinfo.c.h
generated
@ -80,7 +80,7 @@ zoneinfo_ZoneInfo_from_file_impl(PyTypeObject *type, PyTypeObject *cls,
|
||||
PyObject *file_obj, PyObject *key);
|
||||
|
||||
static PyObject *
|
||||
zoneinfo_ZoneInfo_from_file(PyTypeObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
zoneinfo_ZoneInfo_from_file(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
||||
@ -124,7 +124,7 @@ zoneinfo_ZoneInfo_from_file(PyTypeObject *type, PyTypeObject *cls, PyObject *con
|
||||
}
|
||||
key = args[1];
|
||||
skip_optional_pos:
|
||||
return_value = zoneinfo_ZoneInfo_from_file_impl(type, cls, file_obj, key);
|
||||
return_value = zoneinfo_ZoneInfo_from_file_impl((PyTypeObject *)type, cls, file_obj, key);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
@ -144,7 +144,7 @@ zoneinfo_ZoneInfo_no_cache_impl(PyTypeObject *type, PyTypeObject *cls,
|
||||
PyObject *key);
|
||||
|
||||
static PyObject *
|
||||
zoneinfo_ZoneInfo_no_cache(PyTypeObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
zoneinfo_ZoneInfo_no_cache(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
||||
@ -181,7 +181,7 @@ zoneinfo_ZoneInfo_no_cache(PyTypeObject *type, PyTypeObject *cls, PyObject *cons
|
||||
goto exit;
|
||||
}
|
||||
key = args[0];
|
||||
return_value = zoneinfo_ZoneInfo_no_cache_impl(type, cls, key);
|
||||
return_value = zoneinfo_ZoneInfo_no_cache_impl((PyTypeObject *)type, cls, key);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
@ -201,7 +201,7 @@ zoneinfo_ZoneInfo_clear_cache_impl(PyTypeObject *type, PyTypeObject *cls,
|
||||
PyObject *only_keys);
|
||||
|
||||
static PyObject *
|
||||
zoneinfo_ZoneInfo_clear_cache(PyTypeObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
zoneinfo_ZoneInfo_clear_cache(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
||||
@ -244,7 +244,7 @@ zoneinfo_ZoneInfo_clear_cache(PyTypeObject *type, PyTypeObject *cls, PyObject *c
|
||||
only_keys = args[0];
|
||||
skip_optional_kwonly:
|
||||
Py_BEGIN_CRITICAL_SECTION(type);
|
||||
return_value = zoneinfo_ZoneInfo_clear_cache_impl(type, cls, only_keys);
|
||||
return_value = zoneinfo_ZoneInfo_clear_cache_impl((PyTypeObject *)type, cls, only_keys);
|
||||
Py_END_CRITICAL_SECTION();
|
||||
|
||||
exit:
|
||||
@ -399,7 +399,7 @@ zoneinfo_ZoneInfo__unpickle_impl(PyTypeObject *type, PyTypeObject *cls,
|
||||
PyObject *key, unsigned char from_cache);
|
||||
|
||||
static PyObject *
|
||||
zoneinfo_ZoneInfo__unpickle(PyTypeObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
zoneinfo_ZoneInfo__unpickle(PyObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
||||
@ -434,9 +434,9 @@ zoneinfo_ZoneInfo__unpickle(PyTypeObject *type, PyTypeObject *cls, PyObject *con
|
||||
from_cache = (unsigned char) ival;
|
||||
}
|
||||
}
|
||||
return_value = zoneinfo_ZoneInfo__unpickle_impl(type, cls, key, from_cache);
|
||||
return_value = zoneinfo_ZoneInfo__unpickle_impl((PyTypeObject *)type, cls, key, from_cache);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=f8a4fb4ff634d6c9 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=786e8579e58c2f1c input=a9049054013a1b77]*/
|
||||
|
15
Modules/clinic/itertoolsmodule.c.h
generated
15
Modules/clinic/itertoolsmodule.c.h
generated
@ -486,6 +486,19 @@ PyDoc_STRVAR(itertools_chain_from_iterable__doc__,
|
||||
#define ITERTOOLS_CHAIN_FROM_ITERABLE_METHODDEF \
|
||||
{"from_iterable", (PyCFunction)itertools_chain_from_iterable, METH_O|METH_CLASS, itertools_chain_from_iterable__doc__},
|
||||
|
||||
static PyObject *
|
||||
itertools_chain_from_iterable_impl(PyTypeObject *type, PyObject *arg);
|
||||
|
||||
static PyObject *
|
||||
itertools_chain_from_iterable(PyObject *type, PyObject *arg)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
|
||||
return_value = itertools_chain_from_iterable_impl((PyTypeObject *)type, arg);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(itertools_combinations__doc__,
|
||||
"combinations(iterable, r)\n"
|
||||
"--\n"
|
||||
@ -936,4 +949,4 @@ skip_optional_pos:
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=199eeac2d17e8f23 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=688855b1dc77bf5a input=a9049054013a1b77]*/
|
||||
|
10
Modules/clinic/selectmodule.c.h
generated
10
Modules/clinic/selectmodule.c.h
generated
@ -693,7 +693,7 @@ static PyObject *
|
||||
select_epoll_fromfd_impl(PyTypeObject *type, int fd);
|
||||
|
||||
static PyObject *
|
||||
select_epoll_fromfd(PyTypeObject *type, PyObject *arg)
|
||||
select_epoll_fromfd(PyObject *type, PyObject *arg)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
int fd;
|
||||
@ -702,7 +702,7 @@ select_epoll_fromfd(PyTypeObject *type, PyObject *arg)
|
||||
if (fd == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = select_epoll_fromfd_impl(type, fd);
|
||||
return_value = select_epoll_fromfd_impl((PyTypeObject *)type, fd);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
@ -1196,7 +1196,7 @@ static PyObject *
|
||||
select_kqueue_fromfd_impl(PyTypeObject *type, int fd);
|
||||
|
||||
static PyObject *
|
||||
select_kqueue_fromfd(PyTypeObject *type, PyObject *arg)
|
||||
select_kqueue_fromfd(PyObject *type, PyObject *arg)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
int fd;
|
||||
@ -1205,7 +1205,7 @@ select_kqueue_fromfd(PyTypeObject *type, PyObject *arg)
|
||||
if (fd == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = select_kqueue_fromfd_impl(type, fd);
|
||||
return_value = select_kqueue_fromfd_impl((PyTypeObject *)type, fd);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
@ -1365,4 +1365,4 @@ exit:
|
||||
#ifndef SELECT_KQUEUE_CONTROL_METHODDEF
|
||||
#define SELECT_KQUEUE_CONTROL_METHODDEF
|
||||
#endif /* !defined(SELECT_KQUEUE_CONTROL_METHODDEF) */
|
||||
/*[clinic end generated code: output=c18fd93efc5f4dce input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=60c3edb2745c9f33 input=a9049054013a1b77]*/
|
||||
|
@ -1843,8 +1843,8 @@ Alternative chain() constructor taking a single iterable argument that evaluates
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
itertools_chain_from_iterable(PyTypeObject *type, PyObject *arg)
|
||||
/*[clinic end generated code: output=667ae7a7f7b68654 input=72c39e3a2ca3be85]*/
|
||||
itertools_chain_from_iterable_impl(PyTypeObject *type, PyObject *arg)
|
||||
/*[clinic end generated code: output=3d7ea7d46b9e43f5 input=72c39e3a2ca3be85]*/
|
||||
{
|
||||
PyObject *source;
|
||||
|
||||
|
@ -2543,8 +2543,8 @@ Example: bytearray.fromhex('B9 01EF') -> bytearray(b'\\xb9\\x01\\xef')
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
bytearray_fromhex(PyTypeObject *type, PyObject *string)
|
||||
/*[clinic end generated code: output=da84dc708e9c4b36 input=7e314e5b2d7ab484]*/
|
||||
bytearray_fromhex_impl(PyTypeObject *type, PyObject *string)
|
||||
/*[clinic end generated code: output=8f0f0b6d30fb3ba0 input=7e314e5b2d7ab484]*/
|
||||
{
|
||||
PyObject *result = _PyBytes_FromHex(string, type == &PyByteArray_Type);
|
||||
if (type != &PyByteArray_Type && result != NULL) {
|
||||
|
@ -2494,8 +2494,8 @@ Example: bytes.fromhex('B9 01EF') -> b'\\xb9\\x01\\xef'.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
bytes_fromhex(PyTypeObject *type, PyObject *string)
|
||||
/*[clinic end generated code: output=d458ec88195da6b3 input=f37d98ed51088a21]*/
|
||||
bytes_fromhex_impl(PyTypeObject *type, PyObject *string)
|
||||
/*[clinic end generated code: output=0973acc63661bb2e input=f37d98ed51088a21]*/
|
||||
{
|
||||
PyObject *result = _PyBytes_FromHex(string, 0);
|
||||
if (type != &PyBytes_Type && result != NULL) {
|
||||
|
15
Objects/clinic/bytearrayobject.c.h
generated
15
Objects/clinic/bytearrayobject.c.h
generated
@ -1601,6 +1601,19 @@ PyDoc_STRVAR(bytearray_fromhex__doc__,
|
||||
#define BYTEARRAY_FROMHEX_METHODDEF \
|
||||
{"fromhex", (PyCFunction)bytearray_fromhex, METH_O|METH_CLASS, bytearray_fromhex__doc__},
|
||||
|
||||
static PyObject *
|
||||
bytearray_fromhex_impl(PyTypeObject *type, PyObject *string);
|
||||
|
||||
static PyObject *
|
||||
bytearray_fromhex(PyObject *type, PyObject *string)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
|
||||
return_value = bytearray_fromhex_impl((PyTypeObject *)type, string);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bytearray_hex__doc__,
|
||||
"hex($self, /, sep=<unrepresentable>, bytes_per_sep=1)\n"
|
||||
"--\n"
|
||||
@ -1769,4 +1782,4 @@ bytearray_sizeof(PyObject *self, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
return bytearray_sizeof_impl((PyByteArrayObject *)self);
|
||||
}
|
||||
/*[clinic end generated code: output=13a4231325b7d3c1 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=b1dce6c12ad1a9e2 input=a9049054013a1b77]*/
|
||||
|
15
Objects/clinic/bytesobject.c.h
generated
15
Objects/clinic/bytesobject.c.h
generated
@ -1204,6 +1204,19 @@ PyDoc_STRVAR(bytes_fromhex__doc__,
|
||||
#define BYTES_FROMHEX_METHODDEF \
|
||||
{"fromhex", (PyCFunction)bytes_fromhex, METH_O|METH_CLASS, bytes_fromhex__doc__},
|
||||
|
||||
static PyObject *
|
||||
bytes_fromhex_impl(PyTypeObject *type, PyObject *string);
|
||||
|
||||
static PyObject *
|
||||
bytes_fromhex(PyObject *type, PyObject *string)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
|
||||
return_value = bytes_fromhex_impl((PyTypeObject *)type, string);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bytes_hex__doc__,
|
||||
"hex($self, /, sep=<unrepresentable>, bytes_per_sep=1)\n"
|
||||
"--\n"
|
||||
@ -1384,4 +1397,4 @@ skip_optional_pos:
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=967aae4b46423586 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=60d6a9f1333b76f0 input=a9049054013a1b77]*/
|
||||
|
15
Objects/clinic/complexobject.c.h
generated
15
Objects/clinic/complexobject.c.h
generated
@ -170,4 +170,17 @@ PyDoc_STRVAR(complex_from_number__doc__,
|
||||
|
||||
#define COMPLEX_FROM_NUMBER_METHODDEF \
|
||||
{"from_number", (PyCFunction)complex_from_number, METH_O|METH_CLASS, complex_from_number__doc__},
|
||||
/*[clinic end generated code: output=252cddef7f9169a0 input=a9049054013a1b77]*/
|
||||
|
||||
static PyObject *
|
||||
complex_from_number_impl(PyTypeObject *type, PyObject *number);
|
||||
|
||||
static PyObject *
|
||||
complex_from_number(PyObject *type, PyObject *number)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
|
||||
return_value = complex_from_number_impl((PyTypeObject *)type, number);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=307531cd6d6e7544 input=a9049054013a1b77]*/
|
||||
|
6
Objects/clinic/dictobject.c.h
generated
6
Objects/clinic/dictobject.c.h
generated
@ -18,7 +18,7 @@ static PyObject *
|
||||
dict_fromkeys_impl(PyTypeObject *type, PyObject *iterable, PyObject *value);
|
||||
|
||||
static PyObject *
|
||||
dict_fromkeys(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs)
|
||||
dict_fromkeys(PyObject *type, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *iterable;
|
||||
@ -33,7 +33,7 @@ dict_fromkeys(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs)
|
||||
}
|
||||
value = args[1];
|
||||
skip_optional:
|
||||
return_value = dict_fromkeys_impl(type, iterable, value);
|
||||
return_value = dict_fromkeys_impl((PyTypeObject *)type, iterable, value);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
@ -323,4 +323,4 @@ dict_values(PyObject *self, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
return dict_values_impl((PyDictObject *)self);
|
||||
}
|
||||
/*[clinic end generated code: output=8a104741e4676c76 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=9007b74432217017 input=a9049054013a1b77]*/
|
||||
|
32
Objects/clinic/floatobject.c.h
generated
32
Objects/clinic/floatobject.c.h
generated
@ -165,6 +165,19 @@ PyDoc_STRVAR(float_fromhex__doc__,
|
||||
#define FLOAT_FROMHEX_METHODDEF \
|
||||
{"fromhex", (PyCFunction)float_fromhex, METH_O|METH_CLASS, float_fromhex__doc__},
|
||||
|
||||
static PyObject *
|
||||
float_fromhex_impl(PyTypeObject *type, PyObject *string);
|
||||
|
||||
static PyObject *
|
||||
float_fromhex(PyObject *type, PyObject *string)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
|
||||
return_value = float_fromhex_impl((PyTypeObject *)type, string);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(float_as_integer_ratio__doc__,
|
||||
"as_integer_ratio($self, /)\n"
|
||||
"--\n"
|
||||
@ -236,6 +249,19 @@ PyDoc_STRVAR(float_from_number__doc__,
|
||||
#define FLOAT_FROM_NUMBER_METHODDEF \
|
||||
{"from_number", (PyCFunction)float_from_number, METH_O|METH_CLASS, float_from_number__doc__},
|
||||
|
||||
static PyObject *
|
||||
float_from_number_impl(PyTypeObject *type, PyObject *number);
|
||||
|
||||
static PyObject *
|
||||
float_from_number(PyObject *type, PyObject *number)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
|
||||
return_value = float_from_number_impl((PyTypeObject *)type, number);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(float___getnewargs____doc__,
|
||||
"__getnewargs__($self, /)\n"
|
||||
"--\n"
|
||||
@ -275,7 +301,7 @@ static PyObject *
|
||||
float___getformat___impl(PyTypeObject *type, const char *typestr);
|
||||
|
||||
static PyObject *
|
||||
float___getformat__(PyTypeObject *type, PyObject *arg)
|
||||
float___getformat__(PyObject *type, PyObject *arg)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
const char *typestr;
|
||||
@ -293,7 +319,7 @@ float___getformat__(PyTypeObject *type, PyObject *arg)
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
return_value = float___getformat___impl(type, typestr);
|
||||
return_value = float___getformat___impl((PyTypeObject *)type, typestr);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
@ -327,4 +353,4 @@ float___format__(PyObject *self, PyObject *arg)
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=366cea9463cc5bf6 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=927035897ea3573f input=a9049054013a1b77]*/
|
||||
|
6
Objects/clinic/longobject.c.h
generated
6
Objects/clinic/longobject.c.h
generated
@ -394,7 +394,7 @@ int_from_bytes_impl(PyTypeObject *type, PyObject *bytes_obj,
|
||||
PyObject *byteorder, int is_signed);
|
||||
|
||||
static PyObject *
|
||||
int_from_bytes(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
int_from_bytes(PyObject *type, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
||||
@ -456,7 +456,7 @@ skip_optional_pos:
|
||||
goto exit;
|
||||
}
|
||||
skip_optional_kwonly:
|
||||
return_value = int_from_bytes_impl(type, bytes_obj, byteorder, is_signed);
|
||||
return_value = int_from_bytes_impl((PyTypeObject *)type, bytes_obj, byteorder, is_signed);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
@ -479,4 +479,4 @@ int_is_integer(PyObject *self, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
return int_is_integer_impl(self);
|
||||
}
|
||||
/*[clinic end generated code: output=fb96bd642a643f75 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=591cffa2b80b5184 input=a9049054013a1b77]*/
|
||||
|
6
Objects/clinic/memoryobject.c.h
generated
6
Objects/clinic/memoryobject.c.h
generated
@ -76,7 +76,7 @@ static PyObject *
|
||||
memoryview__from_flags_impl(PyTypeObject *type, PyObject *object, int flags);
|
||||
|
||||
static PyObject *
|
||||
memoryview__from_flags(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
memoryview__from_flags(PyObject *type, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
||||
@ -118,7 +118,7 @@ memoryview__from_flags(PyTypeObject *type, PyObject *const *args, Py_ssize_t nar
|
||||
if (flags == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = memoryview__from_flags_impl(type, object, flags);
|
||||
return_value = memoryview__from_flags_impl((PyTypeObject *)type, object, flags);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
@ -486,4 +486,4 @@ skip_optional:
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=c0371164b68a6839 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=ae3414e9311c02fb input=a9049054013a1b77]*/
|
||||
|
6
Objects/clinic/odictobject.c.h
generated
6
Objects/clinic/odictobject.c.h
generated
@ -21,7 +21,7 @@ static PyObject *
|
||||
OrderedDict_fromkeys_impl(PyTypeObject *type, PyObject *seq, PyObject *value);
|
||||
|
||||
static PyObject *
|
||||
OrderedDict_fromkeys(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
OrderedDict_fromkeys(PyObject *type, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
||||
@ -65,7 +65,7 @@ OrderedDict_fromkeys(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs
|
||||
}
|
||||
value = args[1];
|
||||
skip_optional_pos:
|
||||
return_value = OrderedDict_fromkeys_impl(type, seq, value);
|
||||
return_value = OrderedDict_fromkeys_impl((PyTypeObject *)type, seq, value);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
@ -337,4 +337,4 @@ skip_optional_pos:
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=55bd390bb516e997 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=6f84d0649fcd0c1f input=a9049054013a1b77]*/
|
||||
|
@ -1307,8 +1307,8 @@ Convert number to a complex floating-point number.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
complex_from_number(PyTypeObject *type, PyObject *number)
|
||||
/*[clinic end generated code: output=658a7a5fb0de074d input=3f8bdd3a2bc3facd]*/
|
||||
complex_from_number_impl(PyTypeObject *type, PyObject *number)
|
||||
/*[clinic end generated code: output=7248bb593e1871e1 input=3f8bdd3a2bc3facd]*/
|
||||
{
|
||||
if (PyComplex_CheckExact(number) && type == &PyComplex_Type) {
|
||||
Py_INCREF(number);
|
||||
|
@ -1273,8 +1273,8 @@ Create a floating-point number from a hexadecimal string.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
float_fromhex(PyTypeObject *type, PyObject *string)
|
||||
/*[clinic end generated code: output=46c0274d22b78e82 input=0407bebd354bca89]*/
|
||||
float_fromhex_impl(PyTypeObject *type, PyObject *string)
|
||||
/*[clinic end generated code: output=c54b4923552e5af5 input=0407bebd354bca89]*/
|
||||
{
|
||||
PyObject *result;
|
||||
double x;
|
||||
@ -1687,8 +1687,8 @@ Convert real number to a floating-point number.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
float_from_number(PyTypeObject *type, PyObject *number)
|
||||
/*[clinic end generated code: output=bbcf05529fe907a3 input=1f8424d9bc11866a]*/
|
||||
float_from_number_impl(PyTypeObject *type, PyObject *number)
|
||||
/*[clinic end generated code: output=dda7e4466ab7068d input=1f8424d9bc11866a]*/
|
||||
{
|
||||
if (PyFloat_CheckExact(number) && type == &PyFloat_Type) {
|
||||
Py_INCREF(number);
|
||||
|
@ -1107,7 +1107,8 @@ class Py_buffer_converter(CConverter):
|
||||
|
||||
|
||||
def correct_name_for_self(
|
||||
f: Function
|
||||
f: Function,
|
||||
parser: bool = False
|
||||
) -> tuple[str, str]:
|
||||
if f.kind in {CALLABLE, METHOD_INIT, GETTER, SETTER}:
|
||||
if f.cls:
|
||||
@ -1115,7 +1116,12 @@ def correct_name_for_self(
|
||||
return "PyObject *", "module"
|
||||
if f.kind is STATIC_METHOD:
|
||||
return "void *", "null"
|
||||
if f.kind in (CLASS_METHOD, METHOD_NEW):
|
||||
if f.kind == CLASS_METHOD:
|
||||
if parser:
|
||||
return "PyObject *", "type"
|
||||
else:
|
||||
return "PyTypeObject *", "type"
|
||||
if f.kind == METHOD_NEW:
|
||||
return "PyTypeObject *", "type"
|
||||
raise AssertionError(f"Unhandled type of function f: {f.kind!r}")
|
||||
|
||||
@ -1184,7 +1190,7 @@ class self_converter(CConverter):
|
||||
@property
|
||||
def parser_type(self) -> str:
|
||||
assert self.type is not None
|
||||
tp, _ = correct_name_for_self(self.function)
|
||||
tp, _ = correct_name_for_self(self.function, parser=True)
|
||||
return tp
|
||||
|
||||
def render(self, parameter: Parameter, data: CRenderData) -> None:
|
||||
@ -1229,6 +1235,13 @@ class self_converter(CConverter):
|
||||
type_ptr = f'PyTypeObject *base_tp = {type_object};'
|
||||
template_dict['base_type_ptr'] = type_ptr
|
||||
|
||||
def use_pyobject_self(self, func: Function) -> bool:
|
||||
conv_type = self.type
|
||||
if conv_type is None:
|
||||
conv_type, _ = correct_name_for_self(func)
|
||||
return (conv_type in ('PyObject *', None)
|
||||
and self.specified_type in ('PyObject *', None))
|
||||
|
||||
|
||||
# Converters for var-positional parameter.
|
||||
|
||||
|
@ -296,9 +296,7 @@ class ParseArgsCodeGen:
|
||||
and not self.func.critical_section)
|
||||
|
||||
def use_pyobject_self(self) -> bool:
|
||||
pyobject_types = ('PyObject *', None)
|
||||
return (self.self_parameter_converter.type in pyobject_types
|
||||
and self.self_parameter_converter.specified_type in pyobject_types)
|
||||
return self.self_parameter_converter.use_pyobject_self(self.func)
|
||||
|
||||
def select_prototypes(self) -> None:
|
||||
self.docstring_prototype = ''
|
||||
|
Loading…
x
Reference in New Issue
Block a user