Python: eliminating stack traces into library code?
<p>When I get a runtime exception from the standard library, it's almost always a problem in my code and not in the library code.  Is there a way to truncate the exception stack trace so that it doesn't show the guts of the library package?</p>

<p>For example, I would like to get this:</p>

<pre><code>Traceback (most recent call last):
  File "./lmd3-mkhead.py", line 71, in &lt;module&gt;
    main()
  File "./lmd3-mkhead.py", line 66, in main
    create()
  File "./lmd3-mkhead.py", line 41, in create
    headver1[depotFile]=rev
TypeError: Data values must be of type string or None.
</code></pre>

<p>and not this:</p>

<pre><code>Traceback (most recent call last):
  File "./lmd3-mkhead.py", line 71, in &lt;module&gt;
    main()
  File "./lmd3-mkhead.py", line 66, in main
    create()
  File "./lmd3-mkhead.py", line 41, in create
    headver1[depotFile]=rev
  File "/usr/anim/modsquad/oses/fc11/lib/python2.6/bsddb/__init__.py", line 276, in __setitem__
    _DeadlockWrap(wrapF)  # self.db[key] = value
  File "/usr/anim/modsquad/oses/fc11/lib/python2.6/bsddb/dbutils.py", line 68, in DeadlockWrap
    return function(*_args, **_kwargs)
  File "/usr/anim/modsquad/oses/fc11/lib/python2.6/bsddb/__init__.py", line 275, in wrapF
    self.db[key] = value
TypeError: Data values must be of type string or None.
</code></pre>

<p><strong>update:</strong> added an <a href="http://stackoverflow.com/questions/2615414/python-eliminating-stack-traces-into-library-code/2616262#2616262">answer</a> with the code, thanks to the pointer from Alex.</p>
