2017-02-04 06:13:20 -04:00
|
|
|
/*[clinic input]
|
|
|
|
preserve
|
|
|
|
[clinic start generated code]*/
|
|
|
|
|
2023-10-17 09:30:31 -03:00
|
|
|
#include "pycore_modsupport.h" // _PyArg_CheckPositional()
|
|
|
|
|
2017-02-04 06:13:20 -04:00
|
|
|
PyDoc_STRVAR(_symtable_symtable__doc__,
|
2019-05-28 20:21:17 -03:00
|
|
|
"symtable($module, source, filename, startstr, /)\n"
|
2017-02-04 06:13:20 -04:00
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Return symbol and scope dictionaries used internally by compiler.");
|
|
|
|
|
|
|
|
#define _SYMTABLE_SYMTABLE_METHODDEF \
|
2022-05-03 15:25:41 -03:00
|
|
|
{"symtable", _PyCFunction_CAST(_symtable_symtable), METH_FASTCALL, _symtable_symtable__doc__},
|
2017-02-04 06:13:20 -04:00
|
|
|
|
|
|
|
static PyObject *
|
2019-05-28 20:21:17 -03:00
|
|
|
_symtable_symtable_impl(PyObject *module, PyObject *source,
|
2017-02-04 06:13:20 -04:00
|
|
|
PyObject *filename, const char *startstr);
|
|
|
|
|
|
|
|
static PyObject *
|
2017-12-15 07:11:11 -04:00
|
|
|
_symtable_symtable(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
|
2017-02-04 06:13:20 -04:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
2019-05-28 20:21:17 -03:00
|
|
|
PyObject *source;
|
2017-02-04 06:13:20 -04:00
|
|
|
PyObject *filename;
|
|
|
|
const char *startstr;
|
|
|
|
|
2019-01-11 10:01:14 -04:00
|
|
|
if (!_PyArg_CheckPositional("symtable", nargs, 3, 3)) {
|
|
|
|
goto exit;
|
|
|
|
}
|
2019-05-28 20:21:17 -03:00
|
|
|
source = args[0];
|
2019-01-11 10:01:14 -04:00
|
|
|
if (!PyUnicode_FSDecoder(args[1], &filename)) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
if (!PyUnicode_Check(args[2])) {
|
2019-08-29 11:49:08 -03:00
|
|
|
_PyArg_BadArgument("symtable", "argument 3", "str", args[2]);
|
2019-01-11 10:01:14 -04:00
|
|
|
goto exit;
|
|
|
|
}
|
2023-11-07 18:36:13 -04:00
|
|
|
Py_ssize_t startstr_length;
|
|
|
|
startstr = PyUnicode_AsUTF8AndSize(args[2], &startstr_length);
|
2019-01-11 10:01:14 -04:00
|
|
|
if (startstr == NULL) {
|
|
|
|
goto exit;
|
|
|
|
}
|
2023-11-07 18:36:13 -04:00
|
|
|
if (strlen(startstr) != (size_t)startstr_length) {
|
|
|
|
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
|
|
|
goto exit;
|
|
|
|
}
|
2019-05-28 20:21:17 -03:00
|
|
|
return_value = _symtable_symtable_impl(module, source, filename, startstr);
|
2017-02-04 06:13:20 -04:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
2023-11-07 18:36:13 -04:00
|
|
|
/*[clinic end generated code: output=931964a76a72f850 input=a9049054013a1b77]*/
|