Revision 6671
Added by Aaron Marcuse-Kubitza about 12 years ago
lib/exc.py | ||
---|---|---|
1 | 1 |
# Exception handling |
2 | 2 |
|
3 |
import atexit |
|
3 | 4 |
import copy |
4 |
import atexit |
|
5 | 5 |
import sys |
6 | 6 |
import traceback |
7 |
import warnings |
|
7 | 8 |
|
8 | 9 |
import format |
9 | 10 |
import strings |
... | ... | |
41 | 42 |
|
42 | 43 |
def e_msg(e): |
43 | 44 |
if len(e.args) == 0: return strings.ustr(e) |
44 |
assert util.is_str(e.args[0]) |
|
45 |
return strings.ustr(e.args[0]).rstrip() |
|
45 |
arg0 = e.args[0] |
|
46 |
if not util.is_str(arg0): |
|
47 |
warnings.warn(UserWarning('e.args[0] should be a string: '+repr(arg0))) |
|
48 |
return strings.ustr(arg0).rstrip() |
|
46 | 49 |
|
47 | 50 |
def e_str(e): return e.__class__.__name__+': '+e_msg(e) |
48 | 51 |
|
Also available in: Unified diff
exc.py: e_msg(): Emit a warning instead of an AssertionError if e.args0 isn't a string, to assist in debugging malformed exceptions