(py_db, frame, thread, arg, is_unwind)
| 587 | |
| 588 | |
| 589 | def exception_break(py_db, frame, thread, arg, is_unwind): |
| 590 | exception, value, trace = arg |
| 591 | |
| 592 | if py_db.django_exception_break and exception is not None: |
| 593 | if ( |
| 594 | exception.__name__ in ["VariableDoesNotExist", "TemplateDoesNotExist", "TemplateSyntaxError"] |
| 595 | and not is_unwind |
| 596 | and just_raised(trace) |
| 597 | and not ignore_exception_trace(trace) |
| 598 | ): |
| 599 | if exception.__name__ == "TemplateSyntaxError": |
| 600 | # In this case we don't actually have a regular render frame with the context |
| 601 | # (we didn't really get to that point). |
| 602 | token = getattr(value, "token", None) |
| 603 | |
| 604 | if token is None: |
| 605 | # Django 1.7 does not have token in exception. Try to get it from locals. |
| 606 | token = frame.f_locals.get("token") |
| 607 | |
| 608 | lineno = getattr(token, "lineno", None) |
| 609 | |
| 610 | original_filename = None |
| 611 | if lineno is not None: |
| 612 | original_filename = _get_original_filename_from_origin_in_parent_frame_locals(frame, "get_template") |
| 613 | |
| 614 | if original_filename is None: |
| 615 | # Django 1.7 does not have origin in get_template. Try to get it from |
| 616 | # load_template. |
| 617 | original_filename = _get_original_filename_from_origin_in_parent_frame_locals(frame, "load_template") |
| 618 | |
| 619 | if original_filename is not None and lineno is not None: |
| 620 | syntax_error_frame = DjangoTemplateSyntaxErrorFrame( |
| 621 | frame, original_filename, lineno, {"token": token, "exception": exception} |
| 622 | ) |
| 623 | |
| 624 | suspend_frame = suspend_django(py_db, thread, syntax_error_frame, CMD_ADD_EXCEPTION_BREAK) |
| 625 | return True, suspend_frame |
| 626 | |
| 627 | elif exception.__name__ == "VariableDoesNotExist": |
| 628 | if _is_django_variable_does_not_exist_exception_break_context(frame): |
| 629 | if not getattr(exception, "silent_variable_failure", False) and not _is_ignoring_failures(frame): |
| 630 | render_frame = _find_django_render_frame(frame) |
| 631 | if render_frame: |
| 632 | suspend_frame = suspend_django(py_db, thread, DjangoTemplateFrame(render_frame), CMD_ADD_EXCEPTION_BREAK) |
| 633 | if suspend_frame: |
| 634 | add_exception_to_frame(suspend_frame, (exception, value, trace)) |
| 635 | thread.additional_info.pydev_message = "VariableDoesNotExist" |
| 636 | suspend_frame.f_back = frame |
| 637 | frame = suspend_frame |
| 638 | return True, frame |
| 639 | |
| 640 | return None |
nothing calls this directly
no test coverage detected