Skip to content

Commit ac1ca57

Browse files
committed
fix traceback object init
1 parent accadf9 commit ac1ca57

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

py/objexcept.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,17 +553,18 @@ void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qs
553553
mp_obj_exception_t *self = get_native_exception(self_in);
554554

555555
// Try to allocate memory for the traceback, with fallback to emergency traceback object
556-
557556
if (self->traceback == NULL || self->traceback == (mp_obj_traceback_t *)&mp_const_empty_traceback_obj) {
558557
self->traceback = m_new_obj_maybe(mp_obj_traceback_t);
559558
if (self->traceback == NULL) {
560559
self->traceback = &MP_STATE_VM(mp_emergency_traceback_obj);
561560
}
562561
}
563562

564-
// append this traceback info to traceback data
565-
// if memory allocation fails (eg because gc is locked), just return
563+
// populate traceback object
564+
*self->traceback = mp_const_empty_traceback_obj;
566565

566+
// append the provided traceback info to traceback data
567+
// if memory allocation fails (eg because gc is locked), just return
567568
if (self->traceback->data == NULL) {
568569
self->traceback->data = m_new_maybe(size_t, TRACEBACK_ENTRY_LEN);
569570
if (self->traceback->data == NULL) {

0 commit comments

Comments
 (0)