Return True if the current frame has a var __tracebackhide__ resolving to True. If __tracebackhide__ is a callable, it gets called with the ExceptionInfo instance and can decide whether to hide the traceback. Mostly for internal use.
(self, excinfo: ExceptionInfo[BaseException] | None)
| 312 | source = property(getsource) |
| 313 | |
| 314 | def ishidden(self, excinfo: ExceptionInfo[BaseException] | None) -> bool: |
| 315 | """Return True if the current frame has a var __tracebackhide__ |
| 316 | resolving to True. |
| 317 | |
| 318 | If __tracebackhide__ is a callable, it gets called with the |
| 319 | ExceptionInfo instance and can decide whether to hide the traceback. |
| 320 | |
| 321 | Mostly for internal use. |
| 322 | """ |
| 323 | tbh: bool | Callable[[ExceptionInfo[BaseException] | None], bool] = False |
| 324 | for maybe_ns_dct in (self.frame.f_locals, self.frame.f_globals): |
| 325 | # in normal cases, f_locals and f_globals are dictionaries |
| 326 | # however via `exec(...)` / `eval(...)` they can be other types |
| 327 | # (even incorrect types!). |
| 328 | # as such, we suppress all exceptions while accessing __tracebackhide__ |
| 329 | try: |
| 330 | tbh = maybe_ns_dct["__tracebackhide__"] |
| 331 | except Exception: |
| 332 | pass |
| 333 | else: |
| 334 | break |
| 335 | if tbh and callable(tbh): |
| 336 | return tbh(excinfo) |
| 337 | return tbh |
| 338 | |
| 339 | def __str__(self) -> str: |
| 340 | name = self.frame.code.name |
no outgoing calls