question about sys.exc_type and sys.exc_value

John Salerno johnjsal at
Sun Mar 5 02:18:27 CET 2006

Here is an exercise from Learning Python that I wrote myself:

import sys
import traceback

class MyError: pass

def oops():
     raise MyError()

def safe(func, *args):
         apply(func, args)
         print 'Got', sys.exc_type, sys.exc_value


And here is the output:

Traceback (most recent call last):
   File "C:/Python24/", line 11, in safe
     apply(func, args)
   File "C:/Python24/", line 7, in oops
     raise MyError()
MyError: <__main__.MyError instance at 0x00B475A8>
Got Queue.Empty

Why does it show Queue.Empty as the values for sys.exc_type and 
sys.exc_value? I guess I can somewhat understand Empty, because the 
instance is basically nothing. But why does it say Queue instead of 
MyError? The sample in the book shows "Got hello world", because hello 
is the error name and world is the extra data. But mine doesn't seem to 
work that way. (They are also using a string exception in the book, 
instead of a class.)


More information about the Python-list mailing list