From f885c2b7698480d6a303154c2da38721453da4ab Mon Sep 17 00:00:00 2001 From: Athanasius Date: Tue, 15 Dec 2020 15:08:36 +0000 Subject: [PATCH 1/2] EDMCLogging: Catch inspect.getframeinfo(frame) not working Maybe with this we'll see something 'here' or later to give a clue as to why this doesn't work on at least two systems. --- EDMCLogging.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/EDMCLogging.py b/EDMCLogging.py index 308e85fc..479fa9bc 100644 --- a/EDMCLogging.py +++ b/EDMCLogging.py @@ -284,7 +284,25 @@ class EDMCContextFilter(logging.Filter): caller_qualname = caller_class_names = '' if frame: # - frame_info = inspect.getframeinfo(frame) + try: + frame_info = inspect.getframeinfo(frame) + raise(IndexError) # TODO: Remove, only for testing + + except Exception: + # Separate from the print below to guarantee we see at least this much. + print('EDMCLogging:EDMCContextFilter:caller_attributes(): Failed in `inspect.getframinfo(frame)`') + + # We want to *attempt* to show something about the nature of 'frame', + # but at this point we can't trust it will work. + try: + print(f'frame: {frame}') + + except Exception: + pass + + # We've given up, so just return all '??' to signal we couldn't get the info + return '??', '??', '??' + args, _, _, value_dict = inspect.getargvalues(frame) if len(args) and args[0] in ('self', 'cls'): frame_class: 'object' = value_dict[args[0]] From 286647869b36186aa2aed4eec92ef091abddcc4e Mon Sep 17 00:00:00 2001 From: Athanasius Date: Tue, 15 Dec 2020 19:35:51 +0000 Subject: [PATCH 2/2] EDMCLogging: Comment out a 'testing' raise() call --- EDMCLogging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EDMCLogging.py b/EDMCLogging.py index 479fa9bc..eae1a222 100644 --- a/EDMCLogging.py +++ b/EDMCLogging.py @@ -286,7 +286,7 @@ class EDMCContextFilter(logging.Filter): # try: frame_info = inspect.getframeinfo(frame) - raise(IndexError) # TODO: Remove, only for testing + # raise(IndexError) # TODO: Remove, only for testing except Exception: # Separate from the print below to guarantee we see at least this much.