skorokithakis / tbvaccine

A small utility to pretty-print Python tracebacks. ⛺

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ValueError: max() arg is an empty sequence

szabolcsdombi opened this issue · comments

Executing:

def x():
    raise Exception('hello')

def a(b):
    b()

a(x)
d:\...>python -m tbvaccine test_stack_trace.py
Error in sys.excepthook:
Traceback (most recent call last):
  File "d:\...\tbvaccine\tbv.py", line 193, in print_exception
    formatted = self._format_tb_string_with_locals(etype, value, tb)
  File "d:\...\tbvaccine\tbv.py", line 173, in _format_tb_string_with_locals
    max_length = max([len(x[0]) for x in var_tuples])
ValueError: max() arg is an empty sequence

Original exception was:
Traceback (most recent call last):
  File "C:\...\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\...\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "d:\...\tbvaccine\__main__.py", line 67, in <module>
    exec(code, variables, variables)
  File "test_stack_trace.py", line 7, in <module>
    a(x)
  File "test_stack_trace.py", line 5, in a
    b()
  File "test_stack_trace.py", line 2, in x
    raise Exception('hello')
Exception: hello

Can you tell me what you expect to happen as well?

If the problem is that TBVaccine didn't detect the lines, I think this has to do with the path detection. Right now it's a bit Unix-specific, but you can tweak _file_in_dir to get that working.

The error is coming from "tbv.py" line 173

Oh, I see. Hmm, it looks like there are no frames in f_locals, although I don't know why that would happen. I will add some defensive code, thanks.

Can you check the latest HEAD and see if that fixed it?

Works fine.
Thank you