You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.0 KiB

  1. /*[clinic input]
  2. preserve
  3. [clinic start generated code]*/
  4. PyDoc_STRVAR(tb_new__doc__,
  5. "TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)\n"
  6. "--\n"
  7. "\n"
  8. "Create a new traceback object.");
  9. static PyObject *
  10. tb_new_impl(PyTypeObject *type, PyObject *tb_next, PyFrameObject *tb_frame,
  11. int tb_lasti, int tb_lineno);
  12. static PyObject *
  13. tb_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
  14. {
  15. PyObject *return_value = NULL;
  16. static const char * const _keywords[] = {"tb_next", "tb_frame", "tb_lasti", "tb_lineno", NULL};
  17. static _PyArg_Parser _parser = {NULL, _keywords, "TracebackType", 0};
  18. PyObject *argsbuf[4];
  19. PyObject * const *fastargs;
  20. Py_ssize_t nargs = PyTuple_GET_SIZE(args);
  21. PyObject *tb_next;
  22. PyFrameObject *tb_frame;
  23. int tb_lasti;
  24. int tb_lineno;
  25. fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 4, 4, 0, argsbuf);
  26. if (!fastargs) {
  27. goto exit;
  28. }
  29. tb_next = fastargs[0];
  30. if (!PyObject_TypeCheck(fastargs[1], &PyFrame_Type)) {
  31. _PyArg_BadArgument("TracebackType", "argument 'tb_frame'", (&PyFrame_Type)->tp_name, fastargs[1]);
  32. goto exit;
  33. }
  34. tb_frame = (PyFrameObject *)fastargs[1];
  35. if (PyFloat_Check(fastargs[2])) {
  36. PyErr_SetString(PyExc_TypeError,
  37. "integer argument expected, got float" );
  38. goto exit;
  39. }
  40. tb_lasti = _PyLong_AsInt(fastargs[2]);
  41. if (tb_lasti == -1 && PyErr_Occurred()) {
  42. goto exit;
  43. }
  44. if (PyFloat_Check(fastargs[3])) {
  45. PyErr_SetString(PyExc_TypeError,
  46. "integer argument expected, got float" );
  47. goto exit;
  48. }
  49. tb_lineno = _PyLong_AsInt(fastargs[3]);
  50. if (tb_lineno == -1 && PyErr_Occurred()) {
  51. goto exit;
  52. }
  53. return_value = tb_new_impl(type, tb_next, tb_frame, tb_lasti, tb_lineno);
  54. exit:
  55. return return_value;
  56. }
  57. /*[clinic end generated code: output=3def6c06248feed8 input=a9049054013a1b77]*/