cknd / stackprinter

Debugging-friendly exceptions for Python
MIT License
1.28k stars 37 forks source link

Stackprinter failed #38

Closed SqrtRyan closed 3 years ago

SqrtRyan commented 3 years ago

Sometimes, in my repl, stackprinter doesn't work. I found the issue though: in the file /usr/local/lib/python3.8/dist-packages/stackprinter/source_inspection.py, on line 64, sometimes max_line_relative is a float; and this error goes away when you make it an int.

In other words (talking to the author here), in /usr/local/lib/python3.8/dist-packages/stackprinter/source_inspection.py, could you please change line 64 from:

max_line_relative = min(len(source_lines), max_line-line_offset)

to

max_line_relative = int(min(len(source_lines), max_line-line_offset))

Thank you!

-Ryan

Btw, here's the error I get:

Stackprinter failed: File "/usr/local/lib/python3.8/dist-packages/stackprinter/source_inspection.py", line 65, in annotate tokens, head_s, head_e = _tokenize(source_lines[:max_line_relative]) TypeError: slice indices must be integers or None or have an index method

So here is your original traceback at least:

Traceback (most recent call last): File "", line 1, in vim(get_module_path('rp.help')) File "/home/ryan/.local/lib/python3.8/site-packages/rp/r.py", line 13146, in get_module_path return get_module_path_from_name(module) File "/home/ryan/.local/lib/python3.8/site-packages/rp/r.py", line 13141, in get_module_path_from_name return importlib.util.find_spec(module_name).origin AttributeError: 'NoneType' object has no attribute 'origin'

spacemanspiff2007 commented 3 years ago

Do you have a code snippet that can reproduce the crash?

cknd commented 3 years ago

Hey! Thanks for the thorough report, I'll have a look. A snippet to reproduce would be great in addition, yes

cknd commented 3 years ago

this should now be fixed in 0.2.5