summaryrefslogtreecommitdiff
path: root/Objects/clinic/codeobject.c.h
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/clinic/codeobject.c.h')
-rw-r--r--Objects/clinic/codeobject.c.h49
1 files changed, 48 insertions, 1 deletions
diff --git a/Objects/clinic/codeobject.c.h b/Objects/clinic/codeobject.c.h
index 7ffdf07e49..629d26580c 100644
--- a/Objects/clinic/codeobject.c.h
+++ b/Objects/clinic/codeobject.c.h
@@ -373,4 +373,51 @@ skip_optional_kwonly:
exit:
return return_value;
}
-/*[clinic end generated code: output=a272b22f63ea002e input=a9049054013a1b77]*/
+
+PyDoc_STRVAR(code__varname_from_oparg__doc__,
+"_varname_from_oparg($self, /, oparg, *, cell=False)\n"
+"--\n"
+"\n"
+"(internal-only) Return the local variable name for the given oparg.\n"
+"\n"
+"WARNING: this method is for internal use only and may change or go away.");
+
+#define CODE__VARNAME_FROM_OPARG_METHODDEF \
+ {"_varname_from_oparg", (PyCFunction)(void(*)(void))code__varname_from_oparg, METH_FASTCALL|METH_KEYWORDS, code__varname_from_oparg__doc__},
+
+static PyObject *
+code__varname_from_oparg_impl(PyCodeObject *self, int oparg, int cell);
+
+static PyObject *
+code__varname_from_oparg(PyCodeObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+{
+ PyObject *return_value = NULL;
+ static const char * const _keywords[] = {"oparg", "cell", NULL};
+ static _PyArg_Parser _parser = {NULL, _keywords, "_varname_from_oparg", 0};
+ PyObject *argsbuf[2];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
+ int oparg;
+ int cell = 0;
+
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ oparg = _PyLong_AsInt(args[0]);
+ if (oparg == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (!noptargs) {
+ goto skip_optional_kwonly;
+ }
+ cell = PyObject_IsTrue(args[1]);
+ if (cell < 0) {
+ goto exit;
+ }
+skip_optional_kwonly:
+ return_value = code__varname_from_oparg_impl(self, oparg, cell);
+
+exit:
+ return return_value;
+}
+/*[clinic end generated code: output=43f4eef80d584fe0 input=a9049054013a1b77]*/