miso-belica/diagnostics

KeyError raised for deleted routine argument

miso-belica opened this issue · 0 comments

If routine argument is deleted it's not available in dictionary with locals. Example bellow (code and corresponding traceback).

def function_or_method(connection, cursor, errorclass, errorvalue):
    # some very important code ...
    del cursor
    del connection
Error in sys.excepthook:
Traceback (most recent call last):
  File "/diagnostics/__init__.py", line 50, in __call__
    self.storage.save(data, exception_info)
  File "/diagnostics/storages.py", line 26, in save
    file_path = self._build_path_to_file(exception_info)
  File "/diagnostics/storages.py", line 43, in _build_path_to_file
    exception_hash = exception_info.hash()
  File "/diagnostics/models/excinfo.py", line 74, in hash
    frames = [(f.path_to_file, f.source_line) for f in self.frames]
  File "/diagnostics/models/excinfo.py", line 59, in frames
    frames.append(Frame(traceback.tb_frame, frame_order))
  File "/diagnostics/models/frame.py", line 18, in __init__
    self._routine_arguments, self._locals = self._build_locals()
  File "/diagnostics/models/frame.py", line 75, in _build_locals
    local_vars)
  File "/diagnostics/models/frame.py", line 87, in _build_routine_arguments
    variable = Variable(name, local_vars[name])
KeyError: 'connection'