mirror of
https://github.com/Textualize/rich.git
synced 2025-08-04 01:58:24 +00:00
[traceback] Make _rich_traceback_guard
more consistent with _rich_traceback_omit
This commit is contained in:
parent
740b89f49a
commit
f0ca6ff2bc
2 changed files with 4 additions and 3 deletions
|
@ -367,7 +367,7 @@ class Traceback:
|
|||
if filename and not filename.startswith("<"):
|
||||
if not os.path.isabs(filename):
|
||||
filename = os.path.join(_IMPORT_CWD, filename)
|
||||
if frame_summary.f_locals.get("_rich_traceback_omit", False) is True:
|
||||
if frame_summary.f_locals.get("_rich_traceback_omit", False):
|
||||
continue
|
||||
frame = Frame(
|
||||
filename=filename or "?",
|
||||
|
@ -385,7 +385,7 @@ class Traceback:
|
|||
else None,
|
||||
)
|
||||
append(frame)
|
||||
if "_rich_traceback_guard" in frame_summary.f_locals:
|
||||
if frame_summary.f_locals.get("_rich_traceback_guard", False):
|
||||
del stack.frames[:]
|
||||
|
||||
cause = getattr(exc_value, "__cause__", None)
|
||||
|
|
|
@ -326,7 +326,8 @@ def test_rich_traceback_omit_optional_local_flag(
|
|||
return level2()
|
||||
|
||||
def level2():
|
||||
_rich_traceback_omit = rich_traceback_omit_for_level2
|
||||
# true-ish values are enough to trigger the opt-out:
|
||||
_rich_traceback_omit = 1 if rich_traceback_omit_for_level2 else 0
|
||||
return level3()
|
||||
|
||||
def level3():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue