Nathaniel J. Smith | e46a8af | 2018-01-07 05:30:18 -0800 | [diff] [blame] | 1 | /*[clinic input] |
| 2 | preserve |
| 3 | [clinic start generated code]*/ |
| 4 | |
| 5 | PyDoc_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 | |
| 11 | static PyObject * |
| 12 | tb_new_impl(PyTypeObject *type, PyObject *tb_next, PyFrameObject *tb_frame, |
| 13 | int tb_lasti, int tb_lineno); |
| 14 | |
| 15 | static PyObject * |
| 16 | tb_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 Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 20 | 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. Smith | e46a8af | 2018-01-07 05:30:18 -0800 | [diff] [blame] | 24 | PyObject *tb_next; |
| 25 | PyFrameObject *tb_frame; |
| 26 | int tb_lasti; |
| 27 | int tb_lineno; |
| 28 | |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 29 | 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)) { |
Rémi Lapeyre | 4901fe2 | 2019-08-29 16:49:08 +0200 | [diff] [blame] | 35 | _PyArg_BadArgument("TracebackType", "argument 'tb_frame'", (&PyFrame_Type)->tp_name, fastargs[1]); |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 36 | goto exit; |
| 37 | } |
| 38 | tb_frame = (PyFrameObject *)fastargs[1]; |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 39 | tb_lasti = _PyLong_AsInt(fastargs[2]); |
| 40 | if (tb_lasti == -1 && PyErr_Occurred()) { |
| 41 | goto exit; |
| 42 | } |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 43 | tb_lineno = _PyLong_AsInt(fastargs[3]); |
| 44 | if (tb_lineno == -1 && PyErr_Occurred()) { |
Nathaniel J. Smith | e46a8af | 2018-01-07 05:30:18 -0800 | [diff] [blame] | 45 | goto exit; |
| 46 | } |
| 47 | return_value = tb_new_impl(type, tb_next, tb_frame, tb_lasti, tb_lineno); |
| 48 | |
| 49 | exit: |
| 50 | return return_value; |
| 51 | } |
Serhiy Storchaka | 578c395 | 2020-05-26 18:43:38 +0300 | [diff] [blame] | 52 | /*[clinic end generated code: output=403778d7af5ebef9 input=a9049054013a1b77]*/ |