| 423 | return res |
| 424 | |
| 425 | def is_recursion_error(etype, value, records): |
| 426 | try: |
| 427 | # RecursionError is new in Python 3.5 |
| 428 | recursion_error_type = RecursionError |
| 429 | except NameError: |
| 430 | recursion_error_type = RuntimeError |
| 431 | |
| 432 | # The default recursion limit is 1000, but some of that will be taken up |
| 433 | # by stack frames in IPython itself. >500 frames probably indicates |
| 434 | # a recursion error. |
| 435 | return (etype is recursion_error_type) \ |
| 436 | and "recursion" in str(value).lower() \ |
| 437 | and len(records) > _FRAME_RECURSION_LIMIT |
| 438 | |
| 439 | def find_recursion(etype, value, records): |
| 440 | """Identify the repeating stack frames from a RecursionError traceback |