Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Wishlist Beta: Traceback should show path to file
-
When I have a traceback, I only see something like
ValueError: .... . Traceback: config.py line 661: ...
. I dont see which config.py on which path it is. Please improve the message.Georg
-
The same is true for Python on Mac, Linux, Windows, etc.
-
This is what I see on my Windows PC:
C:\Users\georg\Anaconda\python.exe D:/Users/Georg/GitHub/PythonistaPrograms/pip/runPip.py search pip Exception: Traceback (most recent call last): File "D:\Users\Georg\GitHub\PythonistaPrograms\pip\pip\basecommand.py", line 211, in main status = self.run(options, args) File "D:\Users\Georg\GitHub\PythonistaPrograms\pip\pip\commands\list.py", line 94, in run raise ValueError("Test") ValueError: Test
In Pythonista, I would only see "list.py: line 94..., basecommand.py: line 211 etc.. The path name is missing here. To be sure: I do like the ease of how I can navigate tracebacks in Pythonista. I just cannot see which file on which path exactly it is.
Georg
-
You may use StaSh to provide more traceback info. It is disabled by default. You can enable it by type and run
stashconf py_traceback 1
.Now when a script is invoked from within StaSh, it will give you a full traceback report if error occurs.
Even more, you can choose to be dropped into a pdb shell for interactive debugging. This is enabled by
stashconf py_pdb 1
.If you want persist these settings across sessions, put them in the stash config file,
.stash_config
, under stash installation root as follows:[system] py_traceback=1 py_pdb=1
-
You could also put a simple script like this in the "Editor Actions" menu:
import traceback traceback.print_last()
-
Cool!
As Ideas for the product:- make the Editor Action Part of the Standard Produkt. Maybe as an Action item on the Special Traceback view of the Editor.
- make "run with pdb" an Option on the run (>) Button, Maybe when Held down for a longer Time
Just Dreamlng 😀
Georg -
import pdb; pdb.pm()
does work, though of course exceptions in threads are not catchable like this. i also use pdb.settrace in my code where i want to trigger the debugger.
an idea i have had, but never worked on seriously, would be to subclass Pdb/Bdb to incorporate more of a visual debugger. for instance keeping the editor line in sync with the current debug line, watchlists, etc. I played around a little using codemirror inside a webview which allows things like setting of breakpoints, line highlighting, etc.