Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
allendowney
GitHub Repository: allendowney/cpython
Path: blob/main/Python/clinic/traceback.c.h
12 views
1
/*[clinic input]
2
preserve
3
[clinic start generated code]*/
4
5
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6
# include "pycore_gc.h" // PyGC_Head
7
# include "pycore_runtime.h" // _Py_ID()
8
#endif
9
10
11
PyDoc_STRVAR(tb_new__doc__,
12
"TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)\n"
13
"--\n"
14
"\n"
15
"Create a new traceback object.");
16
17
static PyObject *
18
tb_new_impl(PyTypeObject *type, PyObject *tb_next, PyFrameObject *tb_frame,
19
int tb_lasti, int tb_lineno);
20
21
static PyObject *
22
tb_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
23
{
24
PyObject *return_value = NULL;
25
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
26
27
#define NUM_KEYWORDS 4
28
static struct {
29
PyGC_Head _this_is_not_used;
30
PyObject_VAR_HEAD
31
PyObject *ob_item[NUM_KEYWORDS];
32
} _kwtuple = {
33
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
34
.ob_item = { &_Py_ID(tb_next), &_Py_ID(tb_frame), &_Py_ID(tb_lasti), &_Py_ID(tb_lineno), },
35
};
36
#undef NUM_KEYWORDS
37
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
38
39
#else // !Py_BUILD_CORE
40
# define KWTUPLE NULL
41
#endif // !Py_BUILD_CORE
42
43
static const char * const _keywords[] = {"tb_next", "tb_frame", "tb_lasti", "tb_lineno", NULL};
44
static _PyArg_Parser _parser = {
45
.keywords = _keywords,
46
.fname = "TracebackType",
47
.kwtuple = KWTUPLE,
48
};
49
#undef KWTUPLE
50
PyObject *argsbuf[4];
51
PyObject * const *fastargs;
52
Py_ssize_t nargs = PyTuple_GET_SIZE(args);
53
PyObject *tb_next;
54
PyFrameObject *tb_frame;
55
int tb_lasti;
56
int tb_lineno;
57
58
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 4, 4, 0, argsbuf);
59
if (!fastargs) {
60
goto exit;
61
}
62
tb_next = fastargs[0];
63
if (!PyObject_TypeCheck(fastargs[1], &PyFrame_Type)) {
64
_PyArg_BadArgument("TracebackType", "argument 'tb_frame'", (&PyFrame_Type)->tp_name, fastargs[1]);
65
goto exit;
66
}
67
tb_frame = (PyFrameObject *)fastargs[1];
68
tb_lasti = _PyLong_AsInt(fastargs[2]);
69
if (tb_lasti == -1 && PyErr_Occurred()) {
70
goto exit;
71
}
72
tb_lineno = _PyLong_AsInt(fastargs[3]);
73
if (tb_lineno == -1 && PyErr_Occurred()) {
74
goto exit;
75
}
76
return_value = tb_new_impl(type, tb_next, tb_frame, tb_lasti, tb_lineno);
77
78
exit:
79
return return_value;
80
}
81
/*[clinic end generated code: output=7bc9927e362fdfb7 input=a9049054013a1b77]*/
82
83