This website requires JavaScript.
Explore
Help
Sign In
djsundog
/
circuitpython
Watch
1
Star
0
Fork
0
You've already forked circuitpython
Code
Issues
Pull Requests
Packages
Projects
Releases
Wiki
Activity
48e9262f55
circuitpython
/
tests
/
micropython
/
emg_exc.py.exp
5 lines
66 B
Plaintext
Raw
Normal View
History
Unescape
Escape
py/objexcept: Prevent infinite recursion when allocating exceptions. The aim of this patch is to rewrite the functions that create exception instances (mp_obj_exception_make_new and mp_obj_new_exception_msg_varg) so that they do not call any functions that may raise an exception. Otherwise it's possible to create infinite recursion with an exception being raised while trying to create an exception object. The two main things that are done to accomplish this are: 1. Change mp_obj_new_exception_msg_varg to just format the string, then call mp_obj_exception_make_new to actually create the exception object. 2. In mp_obj_exception_make_new and mp_obj_new_exception_msg_varg try to allocate all memory first using functions that don't raise exceptions If any of the memory allocations fail (return NULL) then degrade gracefully by trying other options for memory allocation, eg using the emergency exception buffer. 3. Use a custom printer backend to conservatively format strings: if it can't allocate memory then it just truncates the string. As part of this rewrite, raising an exception without a message, like KeyError(123), will now use the emergency buffer to store the arg and traceback data if there is no heap memory available. Memory use with this patch is unchanged. Code size is increased by: bare-arm: +136 minimal x86: +124 unix x64: +72 unix nanbox: +96 stm32: +88 esp8266: +92 cc3200: +80
2017-09-21 01:24:57 -04:00
Traceback (most recent call last):
, line 20, in f
ValueError: 1
Reference in New Issue
Copy Permalink