update traceback module

This commit is contained in:
microDev 2021-08-04 12:22:21 +05:30
parent 193a8d2e67
commit fb0f2583db
No known key found for this signature in database
GPG Key ID: 2C0867BE60967730
2 changed files with 9 additions and 10 deletions

View File

@ -3421,6 +3421,10 @@ msgstr ""
msgid "invalid syntax for number" msgid "invalid syntax for number"
msgstr "" msgstr ""
#: py/objexcept.c shared-bindings/traceback/__init__.c
msgid "invalid traceback"
msgstr ""
#: py/objtype.c #: py/objtype.c
msgid "issubclass() arg 1 must be a class" msgid "issubclass() arg 1 must be a class"
msgstr "" msgstr ""
@ -4093,10 +4097,6 @@ msgstr ""
msgid "source palette too large" msgid "source palette too large"
msgstr "" msgstr ""
#: shared-bindings/traceback/__init__.c
msgid "stack is not ok"
msgstr ""
#: py/objstr.c #: py/objstr.c
msgid "start/end indices" msgid "start/end indices"
msgstr "" msgstr ""

View File

@ -27,8 +27,6 @@
#include "py/stream.h" #include "py/stream.h"
#include "py/runtime.h" #include "py/runtime.h"
#include "supervisor/shared/stack.h"
//| """Traceback Module //| """Traceback Module
//| //|
//| This module provides a standard interface to print stack traces of programs. //| This module provides a standard interface to print stack traces of programs.
@ -97,11 +95,12 @@ STATIC mp_obj_t traceback_print_exception(size_t n_args, const mp_obj_t *pos_arg
} }
if (args[ARG_tb].u_obj != mp_const_none && print_tb) { if (args[ARG_tb].u_obj != mp_const_none && print_tb) {
if (!stack_ok()) { if (!mp_obj_is_type(args[ARG_tb].u_obj, &mp_type_traceback)) {
mp_raise_RuntimeError(translate("stack is not ok")); mp_raise_TypeError(translate("invalid traceback"));
} }
size_t n, *values; mp_obj_traceback_t *tb = MP_OBJ_TO_PTR(args[ARG_tb].u_obj);
mp_obj_exception_get_traceback(exc, &n, &values); size_t n = (tb->data) ? tb->len : 0;
size_t *values = (tb->data) ? tb->data : NULL;
if (n > 0) { if (n > 0) {
assert(n % 3 == 0); assert(n % 3 == 0);
// Decompress the format strings // Decompress the format strings