Standard Exception Classes in Python 1.5

Standard Exception Classes in Python 1.5

Fatal Breakage

More serious is breaking error handling code. This usually happens because the error handling code expects the exception or the value associated with the exception to have a particular type (usually string or tuple). With the new scheme, the type is a class and the value is a class instance. For example, the following code will break:

try:
    raise Exception()
except:
    print "Sorry:", sys.exc_type + ":", sys.exc_value

你可能感兴趣的:(exception)