symtablemodule.c.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*[clinic input]
  2. preserve
  3. [clinic start generated code]*/
  4. #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
  5. # include "pycore_gc.h" // PyGC_Head
  6. # include "pycore_runtime.h" // _Py_ID()
  7. #endif
  8. PyDoc_STRVAR(_symtable_symtable__doc__,
  9. "symtable($module, source, filename, startstr, /)\n"
  10. "--\n"
  11. "\n"
  12. "Return symbol and scope dictionaries used internally by compiler.");
  13. #define _SYMTABLE_SYMTABLE_METHODDEF \
  14. {"symtable", _PyCFunction_CAST(_symtable_symtable), METH_FASTCALL, _symtable_symtable__doc__},
  15. static PyObject *
  16. _symtable_symtable_impl(PyObject *module, PyObject *source,
  17. PyObject *filename, const char *startstr);
  18. static PyObject *
  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. if (!_PyArg_CheckPositional("symtable", nargs, 3, 3)) {
  26. goto exit;
  27. }
  28. source = args[0];
  29. if (!PyUnicode_FSDecoder(args[1], &filename)) {
  30. goto exit;
  31. }
  32. if (!PyUnicode_Check(args[2])) {
  33. _PyArg_BadArgument("symtable", "argument 3", "str", args[2]);
  34. goto exit;
  35. }
  36. Py_ssize_t startstr_length;
  37. startstr = PyUnicode_AsUTF8AndSize(args[2], &startstr_length);
  38. if (startstr == NULL) {
  39. goto exit;
  40. }
  41. if (strlen(startstr) != (size_t)startstr_length) {
  42. PyErr_SetString(PyExc_ValueError, "embedded null character");
  43. goto exit;
  44. }
  45. return_value = _symtable_symtable_impl(module, source, filename, startstr);
  46. exit:
  47. return return_value;
  48. }
  49. /*[clinic end generated code: output=07716ddbd6c7efe1 input=a9049054013a1b77]*/