Can't catch exception of micropython code in C program #12690
Replies: 6 comments 1 reply
-
I also test async code on MicroPython 1.21, running 2 async tasks, and get the same error as above. But with my old build on MicroPython 1.16 ESP32, it's ok (I also tested this code MP 1.16 in 2021, now I test it again).
|
Beta Was this translation helpful? Give feedback.
-
I run test case 2 in the same main thread, then it promtps
|
Beta Was this translation helpful? Give feedback.
-
I run test case 2 in the same main thread, then it promtps
|
Beta Was this translation helpful? Give feedback.
-
I've checked threading port of ESP32 carefully, line by line. And run many tests in REPL main thread, and new mpy thread. I'm sure that this error caused by internal MicroPython in catching exception when running mpy code in other mpy threads. |
Beta Was this translation helpful? Give feedback.
-
In file py/nlrsetjmp.c MPY 1.21, I replace the code of function nlr_jump with the one from MPY 1.16, then it run fine.
And code from MPY 1.21:
The only difference is the call
|
Beta Was this translation helpful? Give feedback.
-
Closing because this was also raised as #12695. I will reply there. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have 3 test cases as below with MicroPython v1.21.0 on ESP32, also in my program.
It prompts
NameError: name 'CMOS' isn't defined
as expected behavior in MicroPython.I can't catch python exception in C code. Exception decoder is:
It can catch exception, but failed at
nlr_pop_jump_callback , *top = (*top)->prev;
, causing ESP32 exception and restart.So, in micropython env REPL, it can catch exception as expected. I think test case 2 must be the same. It must prompt
AttributeError: 'NoneType' object has no attribute 'clear'
, and not causing ESP exception LoadProhibited.So what's wrong with my C code in test case 2?
Thanks,
Cuong.
Beta Was this translation helpful? Give feedback.
All reactions