2018-12-30 05:24:03 -04:00
|
|
|
/*[clinic input]
|
|
|
|
preserve
|
|
|
|
[clinic start generated code]*/
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
tuplegetter_new_impl(PyTypeObject *type, Py_ssize_t index, PyObject *doc);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
tuplegetter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
Py_ssize_t index;
|
|
|
|
PyObject *doc;
|
|
|
|
|
|
|
|
if ((type == &tuplegetter_type) &&
|
|
|
|
!_PyArg_NoKeywords("_tuplegetter", kwargs)) {
|
|
|
|
goto exit;
|
|
|
|
}
|
2019-01-11 10:01:14 -04:00
|
|
|
if (!_PyArg_CheckPositional("_tuplegetter", PyTuple_GET_SIZE(args), 2, 2)) {
|
2018-12-30 05:24:03 -04:00
|
|
|
goto exit;
|
|
|
|
}
|
2019-01-11 10:01:14 -04:00
|
|
|
if (PyFloat_Check(PyTuple_GET_ITEM(args, 0))) {
|
|
|
|
PyErr_SetString(PyExc_TypeError,
|
|
|
|
"integer argument expected, got float" );
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
Py_ssize_t ival = -1;
|
|
|
|
PyObject *iobj = PyNumber_Index(PyTuple_GET_ITEM(args, 0));
|
|
|
|
if (iobj != NULL) {
|
|
|
|
ival = PyLong_AsSsize_t(iobj);
|
|
|
|
Py_DECREF(iobj);
|
|
|
|
}
|
|
|
|
if (ival == -1 && PyErr_Occurred()) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
index = ival;
|
|
|
|
}
|
|
|
|
doc = PyTuple_GET_ITEM(args, 1);
|
2018-12-30 05:24:03 -04:00
|
|
|
return_value = tuplegetter_new_impl(type, index, doc);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
2019-01-11 10:01:14 -04:00
|
|
|
/*[clinic end generated code: output=51bd572577ca7111 input=a9049054013a1b77]*/
|