Branch data Line data Source code
1 : : /*[clinic input] 2 : : preserve 3 : : [clinic start generated code]*/ 4 : : 5 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) 6 : : # include "pycore_gc.h" // PyGC_Head 7 : : # include "pycore_runtime.h" // _Py_ID() 8 : : #endif 9 : : 10 : : 11 : : static PyObject * 12 : : tokenizeriter_new_impl(PyTypeObject *type, const char *source); 13 : : 14 : : static PyObject * 15 : 0 : tokenizeriter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) 16 : : { 17 : 0 : PyObject *return_value = NULL; 18 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) 19 : : 20 : : #define NUM_KEYWORDS 1 21 : : static struct { 22 : : PyGC_Head _this_is_not_used; 23 : : PyObject_VAR_HEAD 24 : : PyObject *ob_item[NUM_KEYWORDS]; 25 : : } _kwtuple = { 26 : : .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) 27 : : .ob_item = { &_Py_ID(source), }, 28 : : }; 29 : : #undef NUM_KEYWORDS 30 : : #define KWTUPLE (&_kwtuple.ob_base.ob_base) 31 : : 32 : : #else // !Py_BUILD_CORE 33 : : # define KWTUPLE NULL 34 : : #endif // !Py_BUILD_CORE 35 : : 36 : : static const char * const _keywords[] = {"source", NULL}; 37 : : static _PyArg_Parser _parser = { 38 : : .keywords = _keywords, 39 : : .fname = "tokenizeriter", 40 : : .kwtuple = KWTUPLE, 41 : : }; 42 : : #undef KWTUPLE 43 : : PyObject *argsbuf[1]; 44 : : PyObject * const *fastargs; 45 : 0 : Py_ssize_t nargs = PyTuple_GET_SIZE(args); 46 : : const char *source; 47 : : 48 [ # # # # : 0 : fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); # # # # ] 49 [ # # ]: 0 : if (!fastargs) { 50 : 0 : goto exit; 51 : : } 52 [ # # ]: 0 : if (!PyUnicode_Check(fastargs[0])) { 53 : 0 : _PyArg_BadArgument("tokenizeriter", "argument 'source'", "str", fastargs[0]); 54 : 0 : goto exit; 55 : : } 56 : : Py_ssize_t source_length; 57 : 0 : source = PyUnicode_AsUTF8AndSize(fastargs[0], &source_length); 58 [ # # ]: 0 : if (source == NULL) { 59 : 0 : goto exit; 60 : : } 61 [ # # ]: 0 : if (strlen(source) != (size_t)source_length) { 62 : 0 : PyErr_SetString(PyExc_ValueError, "embedded null character"); 63 : 0 : goto exit; 64 : : } 65 : 0 : return_value = tokenizeriter_new_impl(type, source); 66 : : 67 : 0 : exit: 68 : 0 : return return_value; 69 : : } 70 : : /*[clinic end generated code: output=8c2c09f651961986 input=a9049054013a1b77]*/