473,385 Members | 1,325 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

dropping into pdb on an exception

How do you set up pdb such that you will automatically
get dropped into its prompt if an unanticipated exception
occurs in a script you are using?

ASPN Python cookbook gives you the following method
which you can add to your script and hook into sys.excepthook.
But is there a way to do it without adding stuff to your
script? (It's okay if this means having to invoke the script
from within pdb, but #1, I don't know how to get it stay inside
pdb in the case of an /unanticipated/ exception. And #2, I
don't know how to pass [the equivalent of] command-line
arguments to a script invoked from within pdb.)

def info(type, value, tb):
if hasattr(sys, 'ps1') or not sys.stderr.isatty():
# we are in interactive mode or we don't have a tty-like
# device, so we call the default hook
sys.__excepthook__(type, value, tb)
else:
import traceback, pdb
# we are NOT in interactive mode, print the exception...
traceback.print_exception(type, value, tb)
print
# ...then start the debugger in post-mortem mode.
pdb.pm()

sys.excepthook = info

Jul 18 '05 #1
0 1145

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: John P | last post by:
Hello, I'm building email messages and attachments via the JavaMail API, which are then sent via sendmail. The attachments are mime attachments of type "application/octet-stream". They are...
8
by: Jon Perez | last post by:
(sorry for the duplicate post, just wanted to make the subject line clearer) How do you set up pdb such that you will automatically get dropped into its prompt if an unanticipated exception...
2
by: Christian Blackburn | last post by:
Hi Gang, I would like to be able to drag and drop documents onto my application and have them open immediately thereafter. Can somebody point me towards a KB article or example? I could find a...
7
by: Ross Mallett | last post by:
I have to drop large numbers of test tables (> 200) fairly often. This operation seems to be very slow. Is there some way to speed up the process of dropping tables?
8
by: sat | last post by:
hi all! I have a doubt regarding the dropping of a column. As i've seen, we have an option like "alter table <table namedrop column <column name>" in oracle. Do we have any method in db2 to drop...
0
by: daz_oldham | last post by:
I've posted on this months ago, and unfortunately for me my problem has come back! Very basically, I am setting a cookie on a given page, a process runs, and then I am doing a response.redirect...
3
by: =?Utf-8?B?TG9nZ2Vy?= | last post by:
Help, I’m applying updates to a web application that used Web Form Designer Generated Code. I’m using Visual Studio 2003. For some reason lines keep dropping out of the code in the .aspx.vb...
1
by: pixelfreaks | last post by:
Hello, I am having a problem in aligning the sidebar and content area in a webpage. I am using css. Consider the below layout. __________________________________________ | ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.