blob: 6506149a7010d635692a2ef84dc3d104020588f5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
import sys, types
def test(obj):
"""
>>> test(Exception('hi'))
Raising: Exception('hi',)
Caught: Exception('hi',)
"""
print u"Raising: %s%r" % (obj.__class__.__name__, obj.args)
try:
raise obj
except:
info = sys.exc_info()
if sys.version_info >= (2,5):
assert isinstance(info[0], type)
else:
assert isinstance(info[0], types.ClassType)
print u"Caught: %s%r" % (info[1].__class__.__name__, info[1].args)
|