import sys
try:
raise "xxx"
except str,e:
print "1",e
except:
print "2",sys.exc_type,sys.exc_value
In the above code a string exception is raised which though deprecated but still a 3rd party library I use uses it.
So how can I catch such exception without relying on catch all, which could be bad.
except str,e: doesn’t catch it? why?
system:
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Here is the solution from python mailing list, not very elegant but will work if can’t avoid the need for such hack