From 4c7fab3c604055281e691b1fb1bd4d254ca83691 Mon Sep 17 00:00:00 2001 From: NightMachinery Date: Fri, 4 Aug 2023 12:55:03 +0330 Subject: [PATCH] IceCreamDebugger ignores exceptions --- icecream/icecream.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/icecream/icecream.py b/icecream/icecream.py index 435518f..0ea4f04 100644 --- a/icecream/icecream.py +++ b/icecream/icecream.py @@ -23,6 +23,7 @@ from contextlib import contextmanager from os.path import basename, realpath from textwrap import dedent +import traceback import colorama import executing @@ -208,8 +209,11 @@ def __init__(self, prefix=DEFAULT_PREFIX, def __call__(self, *args): if self.enabled: - callFrame = inspect.currentframe().f_back - self.outputFunction(self._format(callFrame, *args)) + try: + callFrame = inspect.currentframe().f_back + self.outputFunction(self._format(callFrame, *args)) + except: + print(f"IceCreamDebugger: exception ignored:\n\n {traceback.format_exc()}", sys.stderr) if not args: # E.g. ic(). passthrough = None