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