• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4 
5 PyDoc_STRVAR(_symtable_symtable__doc__,
6 "symtable($module, source, filename, startstr, /)\n"
7 "--\n"
8 "\n"
9 "Return symbol and scope dictionaries used internally by compiler.");
10 
11 #define _SYMTABLE_SYMTABLE_METHODDEF    \
12     {"symtable", (PyCFunction)(void(*)(void))_symtable_symtable, METH_FASTCALL, _symtable_symtable__doc__},
13 
14 static PyObject *
15 _symtable_symtable_impl(PyObject *module, PyObject *source,
16                         PyObject *filename, const char *startstr);
17 
18 static PyObject *
_symtable_symtable(PyObject * module,PyObject * const * args,Py_ssize_t nargs)19 _symtable_symtable(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
20 {
21     PyObject *return_value = NULL;
22     PyObject *source;
23     PyObject *filename;
24     const char *startstr;
25 
26     if (!_PyArg_CheckPositional("symtable", nargs, 3, 3)) {
27         goto exit;
28     }
29     source = args[0];
30     if (!PyUnicode_FSDecoder(args[1], &filename)) {
31         goto exit;
32     }
33     if (!PyUnicode_Check(args[2])) {
34         _PyArg_BadArgument("symtable", "argument 3", "str", args[2]);
35         goto exit;
36     }
37     Py_ssize_t startstr_length;
38     startstr = PyUnicode_AsUTF8AndSize(args[2], &startstr_length);
39     if (startstr == NULL) {
40         goto exit;
41     }
42     if (strlen(startstr) != (size_t)startstr_length) {
43         PyErr_SetString(PyExc_ValueError, "embedded null character");
44         goto exit;
45     }
46     return_value = _symtable_symtable_impl(module, source, filename, startstr);
47 
48 exit:
49     return return_value;
50 }
51 /*[clinic end generated code: output=a12f75cdbdf4e52a input=a9049054013a1b77]*/
52