diff options
| author | Mike Wadsten <mikewadsten@gmail.com> | 2020-01-13 11:51:04 -0600 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2021-10-21 12:32:16 +1100 |
| commit | fe2bc92b4d20c116fbb14b6fe92db459d8ce2126 (patch) | |
| tree | 41abfcf623be9e434c54047acee3bd11a7e3a96b /py | |
| parent | 30268c93dc52116bc6c2041c55de486180b4eb03 (diff) | |
py/runtime: Fix crash when exc __new__ doesn't return an exc instance.
See CPython bug https://bugs.python.org/issue39091 for more details.
Diffstat (limited to 'py')
| -rw-r--r-- | py/runtime.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/py/runtime.c b/py/runtime.c index 0133d813f..27e77fc29 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -1372,8 +1372,10 @@ mp_obj_t mp_make_raise_obj(mp_obj_t o) { // create and return a new exception instance by calling o // TODO could have an option to disable traceback, then builtin exceptions (eg TypeError) // could have const instances in ROM which we return here instead - return mp_call_function_n_kw(o, 0, 0, NULL); - } else if (mp_obj_is_exception_instance(o)) { + o = mp_call_function_n_kw(o, 0, 0, NULL); + } + + if (mp_obj_is_exception_instance(o)) { // o is an instance of an exception, so use it as the exception return o; } else { |
