(self, exc_value, tb)
| 535 | return frames |
| 536 | |
| 537 | def get_exception_traceback_frames(self, exc_value, tb): |
| 538 | exc_cause = self._get_explicit_or_implicit_cause(exc_value) |
| 539 | exc_cause_explicit = getattr(exc_value, "__cause__", True) |
| 540 | if tb is None: |
| 541 | yield { |
| 542 | "exc_cause": exc_cause, |
| 543 | "exc_cause_explicit": exc_cause_explicit, |
| 544 | "tb": None, |
| 545 | "type": "user", |
| 546 | } |
| 547 | while tb is not None: |
| 548 | # Support for __traceback_hide__ which is used by a few libraries |
| 549 | # to hide internal frames. |
| 550 | if tb.tb_frame.f_locals.get("__traceback_hide__"): |
| 551 | tb = tb.tb_next |
| 552 | continue |
| 553 | filename = tb.tb_frame.f_code.co_filename |
| 554 | function = tb.tb_frame.f_code.co_name |
| 555 | lineno = tb.tb_lineno - 1 |
| 556 | loader = tb.tb_frame.f_globals.get("__loader__") |
| 557 | module_name = tb.tb_frame.f_globals.get("__name__") or "" |
| 558 | ( |
| 559 | pre_context_lineno, |
| 560 | pre_context, |
| 561 | context_line, |
| 562 | post_context, |
| 563 | ) = self._get_lines_from_file( |
| 564 | filename, |
| 565 | lineno, |
| 566 | 7, |
| 567 | loader, |
| 568 | module_name, |
| 569 | ) |
| 570 | if pre_context_lineno is None: |
| 571 | pre_context_lineno = lineno |
| 572 | pre_context = [] |
| 573 | context_line = "<source code not available>" |
| 574 | post_context = [] |
| 575 | |
| 576 | colno = tb_area_colno = "" |
| 577 | _, _, start_column, end_column = next( |
| 578 | itertools.islice( |
| 579 | tb.tb_frame.f_code.co_positions(), tb.tb_lasti // 2, None |
| 580 | ) |
| 581 | ) |
| 582 | if start_column and end_column: |
| 583 | underline = "^" * (end_column - start_column) |
| 584 | spaces = " " * (start_column + len(str(lineno + 1)) + 2) |
| 585 | colno = f"\n{spaces}{underline}" |
| 586 | tb_area_spaces = " " * ( |
| 587 | 4 + start_column - (len(context_line) - len(context_line.lstrip())) |
| 588 | ) |
| 589 | tb_area_colno = f"\n{tb_area_spaces}{underline}" |
| 590 | yield { |
| 591 | "exc_cause": exc_cause, |
| 592 | "exc_cause_explicit": exc_cause_explicit, |
| 593 | "tb": tb, |
| 594 | "type": "django" if module_name.startswith("django.") else "user", |
no test coverage detected