blob: 04daf2a3766988d256b8209ca266ff6af8c7dc6f [file] [log] [blame]
Nathaniel J. Smithe46a8af2018-01-07 05:30:18 -08001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(tb_new__doc__,
6"TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)\n"
7"--\n"
8"\n"
9"Create a new traceback object.");
10
11static PyObject *
12tb_new_impl(PyTypeObject *type, PyObject *tb_next, PyFrameObject *tb_frame,
13 int tb_lasti, int tb_lineno);
14
15static PyObject *
16tb_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
17{
18 PyObject *return_value = NULL;
19 static const char * const _keywords[] = {"tb_next", "tb_frame", "tb_lasti", "tb_lineno", NULL};
Serhiy Storchaka31913912019-03-14 10:32:22 +020020 static _PyArg_Parser _parser = {NULL, _keywords, "TracebackType", 0};
21 PyObject *argsbuf[4];
22 PyObject * const *fastargs;
23 Py_ssize_t nargs = PyTuple_GET_SIZE(args);
Nathaniel J. Smithe46a8af2018-01-07 05:30:18 -080024 PyObject *tb_next;
25 PyFrameObject *tb_frame;
26 int tb_lasti;
27 int tb_lineno;
28
Serhiy Storchaka31913912019-03-14 10:32:22 +020029 fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 4, 4, 0, argsbuf);
30 if (!fastargs) {
31 goto exit;
32 }
33 tb_next = fastargs[0];
34 if (!PyObject_TypeCheck(fastargs[1], &PyFrame_Type)) {
Serhiy Storchaka96631dc2019-08-29 18:29:59 +030035 _PyArg_BadArgument("TracebackType", "argument 'tb_frame'", (&PyFrame_Type)->tp_name, fastargs[1]);
Serhiy Storchaka31913912019-03-14 10:32:22 +020036 goto exit;
37 }
38 tb_frame = (PyFrameObject *)fastargs[1];
39 if (PyFloat_Check(fastargs[2])) {
40 PyErr_SetString(PyExc_TypeError,
41 "integer argument expected, got float" );
42 goto exit;
43 }
44 tb_lasti = _PyLong_AsInt(fastargs[2]);
45 if (tb_lasti == -1 && PyErr_Occurred()) {
46 goto exit;
47 }
48 if (PyFloat_Check(fastargs[3])) {
49 PyErr_SetString(PyExc_TypeError,
50 "integer argument expected, got float" );
51 goto exit;
52 }
53 tb_lineno = _PyLong_AsInt(fastargs[3]);
54 if (tb_lineno == -1 && PyErr_Occurred()) {
Nathaniel J. Smithe46a8af2018-01-07 05:30:18 -080055 goto exit;
56 }
57 return_value = tb_new_impl(type, tb_next, tb_frame, tb_lasti, tb_lineno);
58
59exit:
60 return return_value;
61}
Serhiy Storchaka96631dc2019-08-29 18:29:59 +030062/*[clinic end generated code: output=3def6c06248feed8 input=a9049054013a1b77]*/