mirror of https://github.com/python/cpython
gh-101409: Improve generated clinic code for self type checks (#101411)
This commit is contained in:
parent
0062f538d9
commit
2753cf2ed6
|
@ -601,12 +601,13 @@ static int
|
||||||
_io_BufferedRWPair___init__(PyObject *self, PyObject *args, PyObject *kwargs)
|
_io_BufferedRWPair___init__(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
int return_value = -1;
|
int return_value = -1;
|
||||||
|
PyTypeObject *base_tp = &PyBufferedRWPair_Type;
|
||||||
PyObject *reader;
|
PyObject *reader;
|
||||||
PyObject *writer;
|
PyObject *writer;
|
||||||
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
|
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
|
||||||
|
|
||||||
if ((Py_IS_TYPE(self, &PyBufferedRWPair_Type) ||
|
if ((Py_IS_TYPE(self, base_tp) ||
|
||||||
Py_TYPE(self)->tp_new == PyBufferedRWPair_Type.tp_new) &&
|
Py_TYPE(self)->tp_new == base_tp->tp_new) &&
|
||||||
!_PyArg_NoKeywords("BufferedRWPair", kwargs)) {
|
!_PyArg_NoKeywords("BufferedRWPair", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -713,4 +714,4 @@ skip_optional_pos:
|
||||||
exit:
|
exit:
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
/*[clinic end generated code: output=ca87adcfff6a810b input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=953f1577e96e8d86 input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -16,10 +16,11 @@ static int
|
||||||
pysqlite_cursor_init(PyObject *self, PyObject *args, PyObject *kwargs)
|
pysqlite_cursor_init(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
int return_value = -1;
|
int return_value = -1;
|
||||||
|
PyTypeObject *base_tp = clinic_state()->CursorType;
|
||||||
pysqlite_Connection *connection;
|
pysqlite_Connection *connection;
|
||||||
|
|
||||||
if ((Py_IS_TYPE(self, clinic_state()->CursorType) ||
|
if ((Py_IS_TYPE(self, base_tp) ||
|
||||||
Py_TYPE(self)->tp_new == clinic_state()->CursorType->tp_new) &&
|
Py_TYPE(self)->tp_new == base_tp->tp_new) &&
|
||||||
!_PyArg_NoKeywords("Cursor", kwargs)) {
|
!_PyArg_NoKeywords("Cursor", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -318,4 +319,4 @@ pysqlite_cursor_close(pysqlite_Cursor *self, PyObject *Py_UNUSED(ignored))
|
||||||
{
|
{
|
||||||
return pysqlite_cursor_close_impl(self);
|
return pysqlite_cursor_close_impl(self);
|
||||||
}
|
}
|
||||||
/*[clinic end generated code: output=e53e75a32a9d92bd input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=1f82e3c9791bb9a5 input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -16,11 +16,11 @@ static PyObject *
|
||||||
pysqlite_row_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
pysqlite_row_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
PyTypeObject *base_tp = clinic_state()->RowType;
|
||||||
pysqlite_Cursor *cursor;
|
pysqlite_Cursor *cursor;
|
||||||
PyObject *data;
|
PyObject *data;
|
||||||
|
|
||||||
if ((type == clinic_state()->RowType ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == clinic_state()->RowType->tp_init) &&
|
|
||||||
!_PyArg_NoKeywords("Row", kwargs)) {
|
!_PyArg_NoKeywords("Row", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -60,4 +60,4 @@ pysqlite_row_keys(pysqlite_Row *self, PyObject *Py_UNUSED(ignored))
|
||||||
{
|
{
|
||||||
return pysqlite_row_keys_impl(self);
|
return pysqlite_row_keys_impl(self);
|
||||||
}
|
}
|
||||||
/*[clinic end generated code: output=87b91f234633702e input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=157b31ac3f6af1ba input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -46,11 +46,11 @@ static PyObject *
|
||||||
tuplegetter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
tuplegetter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
PyTypeObject *base_tp = &tuplegetter_type;
|
||||||
Py_ssize_t index;
|
Py_ssize_t index;
|
||||||
PyObject *doc;
|
PyObject *doc;
|
||||||
|
|
||||||
if ((type == &tuplegetter_type ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == tuplegetter_type.tp_init) &&
|
|
||||||
!_PyArg_NoKeywords("_tuplegetter", kwargs)) {
|
!_PyArg_NoKeywords("_tuplegetter", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -75,4 +75,4 @@ tuplegetter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
exit:
|
exit:
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
/*[clinic end generated code: output=12168d58a11a4fb9 input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=91a0f221c7b1f96c input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -21,14 +21,13 @@ static PyObject *
|
||||||
simplequeue_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
simplequeue_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
PyTypeObject *base_tp = simplequeue_get_state_by_type(type)->SimpleQueueType;
|
||||||
|
|
||||||
if ((type == simplequeue_get_state_by_type(type)->SimpleQueueType ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == simplequeue_get_state_by_type(type)->SimpleQueueType->tp_init) &&
|
|
||||||
!_PyArg_NoPositional("SimpleQueue", args)) {
|
!_PyArg_NoPositional("SimpleQueue", args)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
if ((type == simplequeue_get_state_by_type(type)->SimpleQueueType ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == simplequeue_get_state_by_type(type)->SimpleQueueType->tp_init) &&
|
|
||||||
!_PyArg_NoKeywords("SimpleQueue", kwargs)) {
|
!_PyArg_NoKeywords("SimpleQueue", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -332,4 +331,4 @@ _queue_SimpleQueue_qsize(simplequeueobject *self, PyObject *Py_UNUSED(ignored))
|
||||||
exit:
|
exit:
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
/*[clinic end generated code: output=628e992d38f50aac input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=9a72a8d1b5767f6a input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -435,10 +435,10 @@ static PyObject *
|
||||||
_ssl__SSLContext(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
_ssl__SSLContext(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
PyTypeObject *base_tp = get_state_type(type)->PySSLContext_Type;
|
||||||
int proto_version;
|
int proto_version;
|
||||||
|
|
||||||
if ((type == get_state_type(type)->PySSLContext_Type ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == get_state_type(type)->PySSLContext_Type->tp_init) &&
|
|
||||||
!_PyArg_NoKeywords("_SSLContext", kwargs)) {
|
!_PyArg_NoKeywords("_SSLContext", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -1028,14 +1028,13 @@ static PyObject *
|
||||||
_ssl_MemoryBIO(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
_ssl_MemoryBIO(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
PyTypeObject *base_tp = get_state_type(type)->PySSLMemoryBIO_Type;
|
||||||
|
|
||||||
if ((type == get_state_type(type)->PySSLMemoryBIO_Type ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == get_state_type(type)->PySSLMemoryBIO_Type->tp_init) &&
|
|
||||||
!_PyArg_NoPositional("MemoryBIO", args)) {
|
!_PyArg_NoPositional("MemoryBIO", args)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
if ((type == get_state_type(type)->PySSLMemoryBIO_Type ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == get_state_type(type)->PySSLMemoryBIO_Type->tp_init) &&
|
|
||||||
!_PyArg_NoKeywords("MemoryBIO", kwargs)) {
|
!_PyArg_NoKeywords("MemoryBIO", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -1543,4 +1542,4 @@ exit:
|
||||||
#ifndef _SSL_ENUM_CRLS_METHODDEF
|
#ifndef _SSL_ENUM_CRLS_METHODDEF
|
||||||
#define _SSL_ENUM_CRLS_METHODDEF
|
#define _SSL_ENUM_CRLS_METHODDEF
|
||||||
#endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */
|
#endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */
|
||||||
/*[clinic end generated code: output=a3d97a19163bb044 input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=4d9b81fa81f520f0 input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -102,10 +102,10 @@ static PyObject *
|
||||||
pairwise_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
pairwise_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
PyTypeObject *base_tp = &pairwise_type;
|
||||||
PyObject *iterable;
|
PyObject *iterable;
|
||||||
|
|
||||||
if ((type == &pairwise_type ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == pairwise_type.tp_init) &&
|
|
||||||
!_PyArg_NoKeywords("pairwise", kwargs)) {
|
!_PyArg_NoKeywords("pairwise", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -195,11 +195,11 @@ static PyObject *
|
||||||
itertools__grouper(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
itertools__grouper(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
PyTypeObject *base_tp = &_grouper_type;
|
||||||
PyObject *parent;
|
PyObject *parent;
|
||||||
PyObject *tgtkey;
|
PyObject *tgtkey;
|
||||||
|
|
||||||
if ((type == &_grouper_type ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == _grouper_type.tp_init) &&
|
|
||||||
!_PyArg_NoKeywords("_grouper", kwargs)) {
|
!_PyArg_NoKeywords("_grouper", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -232,12 +232,12 @@ static PyObject *
|
||||||
itertools_teedataobject(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
itertools_teedataobject(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
PyTypeObject *base_tp = &teedataobject_type;
|
||||||
PyObject *it;
|
PyObject *it;
|
||||||
PyObject *values;
|
PyObject *values;
|
||||||
PyObject *next;
|
PyObject *next;
|
||||||
|
|
||||||
if ((type == &teedataobject_type ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == teedataobject_type.tp_init) &&
|
|
||||||
!_PyArg_NoKeywords("teedataobject", kwargs)) {
|
!_PyArg_NoKeywords("teedataobject", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -270,10 +270,10 @@ static PyObject *
|
||||||
itertools__tee(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
itertools__tee(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
PyTypeObject *base_tp = &tee_type;
|
||||||
PyObject *iterable;
|
PyObject *iterable;
|
||||||
|
|
||||||
if ((type == &tee_type ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == tee_type.tp_init) &&
|
|
||||||
!_PyArg_NoKeywords("_tee", kwargs)) {
|
!_PyArg_NoKeywords("_tee", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -345,10 +345,10 @@ static PyObject *
|
||||||
itertools_cycle(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
itertools_cycle(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
PyTypeObject *base_tp = &cycle_type;
|
||||||
PyObject *iterable;
|
PyObject *iterable;
|
||||||
|
|
||||||
if ((type == &cycle_type ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == cycle_type.tp_init) &&
|
|
||||||
!_PyArg_NoKeywords("cycle", kwargs)) {
|
!_PyArg_NoKeywords("cycle", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -377,11 +377,11 @@ static PyObject *
|
||||||
itertools_dropwhile(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
itertools_dropwhile(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
PyTypeObject *base_tp = &dropwhile_type;
|
||||||
PyObject *func;
|
PyObject *func;
|
||||||
PyObject *seq;
|
PyObject *seq;
|
||||||
|
|
||||||
if ((type == &dropwhile_type ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == dropwhile_type.tp_init) &&
|
|
||||||
!_PyArg_NoKeywords("dropwhile", kwargs)) {
|
!_PyArg_NoKeywords("dropwhile", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -409,11 +409,11 @@ static PyObject *
|
||||||
itertools_takewhile(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
itertools_takewhile(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
PyTypeObject *base_tp = &takewhile_type;
|
||||||
PyObject *func;
|
PyObject *func;
|
||||||
PyObject *seq;
|
PyObject *seq;
|
||||||
|
|
||||||
if ((type == &takewhile_type ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == takewhile_type.tp_init) &&
|
|
||||||
!_PyArg_NoKeywords("takewhile", kwargs)) {
|
!_PyArg_NoKeywords("takewhile", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -441,11 +441,11 @@ static PyObject *
|
||||||
itertools_starmap(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
itertools_starmap(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
PyTypeObject *base_tp = &starmap_type;
|
||||||
PyObject *func;
|
PyObject *func;
|
||||||
PyObject *seq;
|
PyObject *seq;
|
||||||
|
|
||||||
if ((type == &starmap_type ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == starmap_type.tp_init) &&
|
|
||||||
!_PyArg_NoKeywords("starmap", kwargs)) {
|
!_PyArg_NoKeywords("starmap", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -821,11 +821,11 @@ static PyObject *
|
||||||
itertools_filterfalse(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
itertools_filterfalse(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
PyTypeObject *base_tp = &filterfalse_type;
|
||||||
PyObject *func;
|
PyObject *func;
|
||||||
PyObject *seq;
|
PyObject *seq;
|
||||||
|
|
||||||
if ((type == &filterfalse_type ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == filterfalse_type.tp_init) &&
|
|
||||||
!_PyArg_NoKeywords("filterfalse", kwargs)) {
|
!_PyArg_NoKeywords("filterfalse", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -913,4 +913,4 @@ skip_optional_pos:
|
||||||
exit:
|
exit:
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
/*[clinic end generated code: output=0229ebd72962f130 input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=47c8c8ccec8740d7 input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -1061,14 +1061,13 @@ static PyObject *
|
||||||
select_kqueue(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
select_kqueue(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
PyTypeObject *base_tp = _selectstate_by_type(type)->kqueue_queue_Type;
|
||||||
|
|
||||||
if ((type == _selectstate_by_type(type)->kqueue_queue_Type ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == _selectstate_by_type(type)->kqueue_queue_Type->tp_init) &&
|
|
||||||
!_PyArg_NoPositional("kqueue", args)) {
|
!_PyArg_NoPositional("kqueue", args)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
if ((type == _selectstate_by_type(type)->kqueue_queue_Type ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == _selectstate_by_type(type)->kqueue_queue_Type->tp_init) &&
|
|
||||||
!_PyArg_NoKeywords("kqueue", kwargs)) {
|
!_PyArg_NoKeywords("kqueue", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -1310,4 +1309,4 @@ exit:
|
||||||
#ifndef SELECT_KQUEUE_CONTROL_METHODDEF
|
#ifndef SELECT_KQUEUE_CONTROL_METHODDEF
|
||||||
#define SELECT_KQUEUE_CONTROL_METHODDEF
|
#define SELECT_KQUEUE_CONTROL_METHODDEF
|
||||||
#endif /* !defined(SELECT_KQUEUE_CONTROL_METHODDEF) */
|
#endif /* !defined(SELECT_KQUEUE_CONTROL_METHODDEF) */
|
||||||
/*[clinic end generated code: output=9556c7d6cd5192d1 input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=64516114287e894d input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -38,11 +38,11 @@ static PyObject *
|
||||||
method_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
method_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
PyTypeObject *base_tp = &PyMethod_Type;
|
||||||
PyObject *function;
|
PyObject *function;
|
||||||
PyObject *instance;
|
PyObject *instance;
|
||||||
|
|
||||||
if ((type == &PyMethod_Type ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == PyMethod_Type.tp_init) &&
|
|
||||||
!_PyArg_NoKeywords("method", kwargs)) {
|
!_PyArg_NoKeywords("method", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -70,10 +70,10 @@ static PyObject *
|
||||||
instancemethod_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
instancemethod_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
PyTypeObject *base_tp = &PyInstanceMethod_Type;
|
||||||
PyObject *function;
|
PyObject *function;
|
||||||
|
|
||||||
if ((type == &PyInstanceMethod_Type ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == PyInstanceMethod_Type.tp_init) &&
|
|
||||||
!_PyArg_NoKeywords("instancemethod", kwargs)) {
|
!_PyArg_NoKeywords("instancemethod", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -86,4 +86,4 @@ instancemethod_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
exit:
|
exit:
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
/*[clinic end generated code: output=e3294c26a71d456d input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=2a5e7fa5947a86cb input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -30,6 +30,7 @@ static PyObject *
|
||||||
code_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
code_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
PyTypeObject *base_tp = &PyCode_Type;
|
||||||
int argcount;
|
int argcount;
|
||||||
int posonlyargcount;
|
int posonlyargcount;
|
||||||
int kwonlyargcount;
|
int kwonlyargcount;
|
||||||
|
@ -49,8 +50,7 @@ code_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
PyObject *freevars = NULL;
|
PyObject *freevars = NULL;
|
||||||
PyObject *cellvars = NULL;
|
PyObject *cellvars = NULL;
|
||||||
|
|
||||||
if ((type == &PyCode_Type ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == PyCode_Type.tp_init) &&
|
|
||||||
!_PyArg_NoKeywords("code", kwargs)) {
|
!_PyArg_NoKeywords("code", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -488,4 +488,4 @@ code__varname_from_oparg(PyCodeObject *self, PyObject *const *args, Py_ssize_t n
|
||||||
exit:
|
exit:
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
/*[clinic end generated code: output=b6c98f17c60ace53 input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=f1fab6e71c785182 input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -91,10 +91,10 @@ static PyObject *
|
||||||
reversed_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
reversed_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
PyTypeObject *base_tp = &PyReversed_Type;
|
||||||
PyObject *seq;
|
PyObject *seq;
|
||||||
|
|
||||||
if ((type == &PyReversed_Type ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == PyReversed_Type.tp_init) &&
|
|
||||||
!_PyArg_NoKeywords("reversed", kwargs)) {
|
!_PyArg_NoKeywords("reversed", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -107,4 +107,4 @@ reversed_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
exit:
|
exit:
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
/*[clinic end generated code: output=683261097bfd794a input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=aba0ddbeab1601e3 input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -212,10 +212,10 @@ static PyObject *
|
||||||
float_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
float_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
PyTypeObject *base_tp = &PyFloat_Type;
|
||||||
PyObject *x = NULL;
|
PyObject *x = NULL;
|
||||||
|
|
||||||
if ((type == &PyFloat_Type ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == PyFloat_Type.tp_init) &&
|
|
||||||
!_PyArg_NoKeywords("float", kwargs)) {
|
!_PyArg_NoKeywords("float", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -327,4 +327,4 @@ float___format__(PyObject *self, PyObject *arg)
|
||||||
exit:
|
exit:
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
/*[clinic end generated code: output=ac6374ac606a505e input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=74bc91bb44014df9 input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -326,10 +326,11 @@ static int
|
||||||
list___init__(PyObject *self, PyObject *args, PyObject *kwargs)
|
list___init__(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
int return_value = -1;
|
int return_value = -1;
|
||||||
|
PyTypeObject *base_tp = &PyList_Type;
|
||||||
PyObject *iterable = NULL;
|
PyObject *iterable = NULL;
|
||||||
|
|
||||||
if ((Py_IS_TYPE(self, &PyList_Type) ||
|
if ((Py_IS_TYPE(self, base_tp) ||
|
||||||
Py_TYPE(self)->tp_new == PyList_Type.tp_new) &&
|
Py_TYPE(self)->tp_new == base_tp->tp_new) &&
|
||||||
!_PyArg_NoKeywords("list", kwargs)) {
|
!_PyArg_NoKeywords("list", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -382,4 +383,4 @@ list___reversed__(PyListObject *self, PyObject *Py_UNUSED(ignored))
|
||||||
{
|
{
|
||||||
return list___reversed___impl(self);
|
return list___reversed___impl(self);
|
||||||
}
|
}
|
||||||
/*[clinic end generated code: output=4e6f38b655394564 input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=2ca109d8acc775bc input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -81,10 +81,10 @@ static PyObject *
|
||||||
tuple_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
tuple_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
PyObject *return_value = NULL;
|
PyObject *return_value = NULL;
|
||||||
|
PyTypeObject *base_tp = &PyTuple_Type;
|
||||||
PyObject *iterable = NULL;
|
PyObject *iterable = NULL;
|
||||||
|
|
||||||
if ((type == &PyTuple_Type ||
|
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
|
||||||
type->tp_init == PyTuple_Type.tp_init) &&
|
|
||||||
!_PyArg_NoKeywords("tuple", kwargs)) {
|
!_PyArg_NoKeywords("tuple", kwargs)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -118,4 +118,4 @@ tuple___getnewargs__(PyTupleObject *self, PyObject *Py_UNUSED(ignored))
|
||||||
{
|
{
|
||||||
return tuple___getnewargs___impl(self);
|
return tuple___getnewargs___impl(self);
|
||||||
}
|
}
|
||||||
/*[clinic end generated code: output=441d2b880e865f87 input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=48a9e0834b300ac3 input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -1174,6 +1174,7 @@ class CLanguage(Language):
|
||||||
raise ValueError("Slot methods cannot access their defining class.")
|
raise ValueError("Slot methods cannot access their defining class.")
|
||||||
|
|
||||||
if not parses_keywords:
|
if not parses_keywords:
|
||||||
|
declarations = '{base_type_ptr}'
|
||||||
fields.insert(0, normalize_snippet("""
|
fields.insert(0, normalize_snippet("""
|
||||||
if ({self_type_check}!_PyArg_NoKeywords("{name}", kwargs)) {{
|
if ({self_type_check}!_PyArg_NoKeywords("{name}", kwargs)) {{
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -1187,7 +1188,7 @@ class CLanguage(Language):
|
||||||
""", indent=4))
|
""", indent=4))
|
||||||
|
|
||||||
parser_definition = parser_body(parser_prototype, *fields,
|
parser_definition = parser_body(parser_prototype, *fields,
|
||||||
declarations=parser_body_declarations)
|
declarations=declarations)
|
||||||
|
|
||||||
|
|
||||||
if flags in ('METH_NOARGS', 'METH_O', 'METH_VARARGS'):
|
if flags in ('METH_NOARGS', 'METH_O', 'METH_VARARGS'):
|
||||||
|
@ -3839,21 +3840,22 @@ class self_converter(CConverter):
|
||||||
cls = self.function.cls
|
cls = self.function.cls
|
||||||
|
|
||||||
if ((kind in (METHOD_NEW, METHOD_INIT)) and cls and cls.typedef):
|
if ((kind in (METHOD_NEW, METHOD_INIT)) and cls and cls.typedef):
|
||||||
type_object = self.function.cls.type_object
|
|
||||||
prefix = (type_object[1:] + '.' if type_object[0] == '&' else
|
|
||||||
type_object + '->')
|
|
||||||
if kind == METHOD_NEW:
|
if kind == METHOD_NEW:
|
||||||
type_check = ('({0} == {1} ||\n '
|
type_check = (
|
||||||
' {0}->tp_init == {2}tp_init)'
|
'({0} == base_tp || {0}->tp_init == base_tp->tp_init)'
|
||||||
).format(self.name, type_object, prefix)
|
).format(self.name)
|
||||||
else:
|
else:
|
||||||
type_check = ('(Py_IS_TYPE({0}, {1}) ||\n '
|
type_check = ('(Py_IS_TYPE({0}, base_tp) ||\n '
|
||||||
' Py_TYPE({0})->tp_new == {2}tp_new)'
|
' Py_TYPE({0})->tp_new == base_tp->tp_new)'
|
||||||
).format(self.name, type_object, prefix)
|
).format(self.name)
|
||||||
|
|
||||||
line = '{} &&\n '.format(type_check)
|
line = '{} &&\n '.format(type_check)
|
||||||
template_dict['self_type_check'] = line
|
template_dict['self_type_check'] = line
|
||||||
|
|
||||||
|
type_object = self.function.cls.type_object
|
||||||
|
type_ptr = f'PyTypeObject *base_tp = {type_object};'
|
||||||
|
template_dict['base_type_ptr'] = type_ptr
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def add_c_return_converter(f, name=None):
|
def add_c_return_converter(f, name=None):
|
||||||
|
|
Loading…
Reference in New Issue