Extract a Python stacktrace. Python stacktraces are a bit special: they are reversed, and followed by a sanitizer one, so we need to extract them, reverse them, and put their "title" back on top.
(stacktrace)
| 1612 | |
| 1613 | |
| 1614 | def reverse_python_stacktrace(stacktrace): |
| 1615 | """Extract a Python stacktrace. |
| 1616 | Python stacktraces are a bit special: they are reversed, |
| 1617 | and followed by a sanitizer one, so we need to extract them, reverse them, |
| 1618 | and put their "title" back on top.""" |
| 1619 | python_stacktrace_split = [] |
| 1620 | in_python_stacktrace = False |
| 1621 | |
| 1622 | for line in stacktrace: |
| 1623 | # Locate the beginning of the python stacktrace. |
| 1624 | if in_python_stacktrace is False: |
| 1625 | for regex, _ in PYTHON_CRASH_TYPES_MAP: |
| 1626 | if regex.match(line): |
| 1627 | in_python_stacktrace = True |
| 1628 | python_stacktrace_split = [line] # Add the "title" of the stacktrace |
| 1629 | break |
| 1630 | else: |
| 1631 | # Locate beginning of the sanitizer stacktrace. |
| 1632 | if '=========' in line or '== ERROR: ' in line: |
| 1633 | break |
| 1634 | python_stacktrace_split.insert(1, line) |
| 1635 | |
| 1636 | return python_stacktrace_split |
| 1637 | |
| 1638 | |
| 1639 | def update_kasan_crash_details(state, line): |