8000 py/runtime: Fix crash when exc __new__ doesn't return an exc instance. · karfas/micropython@fe2bc92 · GitHub
[go: up one dir, main page]

Skip to content

Commit fe2bc92

Browse files
mikewadstendpgeorge
authored andcommitted
py/runtime: Fix crash when exc __new__ doesn't return an exc instance.
See CPython bug https://bugs.python.org/issue39091 for more details.
1 parent 30268c9 commit fe2bc92

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

py/runtime.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,8 +1372,10 @@ mp_obj_t mp_make_raise_obj(mp_obj_t o) {
13721372
// create and return a new exception instance by calling o
13731373
// TODO could have an option to disable traceback, then builtin exceptions (eg TypeError)
13741374
// could have const instances in ROM which we return here instead
1375-
return mp_call_function_n_kw(o, 0, 0 654C , NULL);
1376-
} else if (mp_obj_is_exception_instance(o)) {
1375+
o = mp_call_function_n_kw(o, 0, 0, NULL);
1376+
}
1377+
1378+
if (mp_obj_is_exception_instance(o)) {
13771379
// o is an instance of an exception, so use it as the exception
13781380
return o;
13791381
} else {

0 commit comments

Comments
 (0)
0