dropping into the debugger on an exception
Thomas Heller
theller at python.net
Wed Jun 9 14:14:12 EDT 2004
Peter Hansen <peter at engcorp.com> writes:
> Jon Perez wrote:
>
>> Thomas Heller wrote:
>>
>>>> Just to be clear: you don't want this to happen all the time,
>>>> you want it to happen only with a particular script, yet you
>>>> don't want to modify that script at all?
>>> I also don't understand *why* he wants to have it that way.
>> Just in case you missed the answer I gave earlier...
>> I don't even want this behaviour all the time with the same
>> script because end-users will be confused if they get dropped
>> into pdb. Believe me, you don't want to explain what pdb is
>> to people who have a hard time even navigating via the
>> command prompt!
>> The best situation would be to be able to invoke this behaviour
>> only when I want it (i.e. during coding/debugging)
>
> Basically this seems to require command line options, right?j
> If so, just include a standard snippet in the __main__ section
> of your scripts which checks the first command line option to
> see if it's "--jon's_special_pdb_magic" (or whatever ;-) ) and
> then programmatically invoke the excepthook stuff...
Or he writes a simple script (debug.py?) by copying the
"if __name__ == '__main__:'" section of lib/pdb.py, and
throws in an additional assignment to sys.excepthook,
and then runs "python debug.py myscript.py <script-args>"
Thomas
More information about the Python-list
mailing list