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)
| 270 | source = property(getsource) |
| 271 | |
| 272 | def ishidden(self) -> bool: |
| 273 | """Return True if the current frame has a var __tracebackhide__ |
| 274 | resolving to True. |
| 275 | |
| 276 | If __tracebackhide__ is a callable, it gets called with the |
| 277 | ExceptionInfo instance and can decide whether to hide the traceback. |
| 278 | |
| 279 | Mostly for internal use. |
| 280 | """ |
| 281 | tbh: Union[ |
| 282 | bool, Callable[[Optional[ExceptionInfo[BaseException]]], bool] |
| 283 | ] = False |
| 284 | for maybe_ns_dct in (self.frame.f_locals, self.frame.f_globals): |
| 285 | # in normal cases, f_locals and f_globals are dictionaries |
| 286 | # however via `exec(...)` / `eval(...)` they can be other types |
| 287 | # (even incorrect types!). |
| 288 | # as such, we suppress all exceptions while accessing __tracebackhide__ |
| 289 | try: |
| 290 | tbh = maybe_ns_dct["__tracebackhide__"] |
| 291 | except Exception: |
| 292 | pass |
| 293 | else: |
| 294 | break |
| 295 | if tbh and callable(tbh): |
| 296 | return tbh(None if self._excinfo is None else self._excinfo()) |
| 297 | return tbh |
| 298 | |
| 299 | def __str__(self) -> str: |
| 300 | name = self.frame.code.name |
no outgoing calls