mp_obj_print_helper: Handle a ctrl-c that comes in during printing

In #2689, hitting ctrl-c during the printing of an object with a lot of sub-objects could cause the screen to stop updating (without showing a KeyboardInterrupt).  This makes the printing of such objects acutally interruptable, and also correctly handles the KeyboardInterrupt:

```
>>> l = ["a" * 100] * 200
>>> l
['aaaaaaaaaaaaaaaaaaaaaa...aaaaaaaaaaa', Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyboardInterrupt:
>>>
```
This commit is contained in:
Jeff Epler 2020-08-25 11:46:49 -05:00
parent e9bc8e892b
commit c0753c1afb

View File

@ -67,6 +67,8 @@ void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
#ifdef RUN_BACKGROUND_TASKS #ifdef RUN_BACKGROUND_TASKS
RUN_BACKGROUND_TASKS; RUN_BACKGROUND_TASKS;
#endif #endif
mp_handle_pending();
#ifndef NDEBUG #ifndef NDEBUG
if (o_in == MP_OBJ_NULL) { if (o_in == MP_OBJ_NULL) {
mp_print_str(print, "(nil)"); mp_print_str(print, "(nil)");