blob: ed3b1b50f9b5820d7b09bc72046443fd2272bcbc [file] [log] [blame]
Pablo Galindo3f5fc702018-12-30 09:24:03 +00001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5static PyObject *
6tuplegetter_new_impl(PyTypeObject *type, Py_ssize_t index, PyObject *doc);
7
8static PyObject *
9tuplegetter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
10{
11 PyObject *return_value = NULL;
12 Py_ssize_t index;
13 PyObject *doc;
14
15 if ((type == &tuplegetter_type) &&
16 !_PyArg_NoKeywords("_tuplegetter", kwargs)) {
17 goto exit;
18 }
Serhiy Storchaka4fa95912019-01-11 16:01:14 +020019 if (!_PyArg_CheckPositional("_tuplegetter", PyTuple_GET_SIZE(args), 2, 2)) {
Pablo Galindo3f5fc702018-12-30 09:24:03 +000020 goto exit;
21 }
Serhiy Storchaka4fa95912019-01-11 16:01:14 +020022 if (PyFloat_Check(PyTuple_GET_ITEM(args, 0))) {
23 PyErr_SetString(PyExc_TypeError,
24 "integer argument expected, got float" );
25 goto exit;
26 }
27 {
28 Py_ssize_t ival = -1;
29 PyObject *iobj = PyNumber_Index(PyTuple_GET_ITEM(args, 0));
30 if (iobj != NULL) {
31 ival = PyLong_AsSsize_t(iobj);
32 Py_DECREF(iobj);
33 }
34 if (ival == -1 && PyErr_Occurred()) {
35 goto exit;
36 }
37 index = ival;
38 }
39 doc = PyTuple_GET_ITEM(args, 1);
Pablo Galindo3f5fc702018-12-30 09:24:03 +000040 return_value = tuplegetter_new_impl(type, index, doc);
41
42exit:
43 return return_value;
44}
Serhiy Storchaka4fa95912019-01-11 16:01:14 +020045/*[clinic end generated code: output=51bd572577ca7111 input=a9049054013a1b77]*/