News for hackers. Stuff that matters.
Re:PySnooper: Never use print for debugging again by cknd on Monday April 22, 2019 @03:41PM (#19722131)
One situation where I would have wanted a real debugger and couldn't use one was in crash reporting on remote systems (like, machine learning code running in some container somewhere, or on a headless box far from the network).

Since Python's built-in tracebacks are pretty minimal, the default crash logs don't offer much help other than a line number. I ended up writing a tool that prints tracebacks along with code context and local variables [i], sort of a souped up version of the built-in crash message. It's surprising how much that already helped in a few situations, makes me wonder why it isn't the default.

So, yes, more debuggers, but also abundant logging everywhere!

[i] https://github.com/cknd/stackprinter

Re:PySnooper: Never use print for debugging again by Gibbon1 on Monday April 22, 2019 @08:40PM (#19724566)
Old school neckbeard way

a) Crashes dump the program state to a file and then you load that in the debugger.

b) If the process is still running but broken, attach the debugger.

c) In my firmware I log bus fault addresses and restart. That allows me to see what code or memory access caused the error. 75% of the time it's fairly obvious what happened.

Re:PySnooper: Never use print for debugging again by int_19h on Monday April 22, 2019 @10:44PM (#19725160)
Crash dump debugging is tricky to implement Python, because its normal debugging APIs - sys.settrace, frame objects etc - require being inside the process with a running Python interpreter.

You can still do it, but you basically have to redo the whole thing from scratch. For example, instead of asking for a repr() of an object to display its value, you have to access the internal representation of it directly - and then accommodate all the differences in that between various Python versions. Something like this (note several different dicts): https://github.com/Microsoft/PTVS/tree/bcdfec4f211488e373fa2...

Re:PySnooper: Never use print for debugging again by yoz on Tuesday April 23, 2019 @12:40AM (#19725660)
Python's standard lib has had something like this for years, but it's been criminally under-promoted (probably because of the terrible name): https://docs.python.org/3/library/cgitb.html

However, yours provides much nicer output. Thank you!