diff options
author | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-02-18 20:30:09 (GMT) |
---|---|---|
committer | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-02-18 20:30:09 (GMT) |
commit | 225a099fe500f4c3577b60ca657eb93a0cd1c735 (patch) | |
tree | f02998dee2a1831460a301afcbb42d77f5f6704e /Lib/unittest/util.py | |
parent | 456e1652cf63dfbd3b1d0af81af9582d204ddd02 (diff) | |
download | cpython-225a099fe500f4c3577b60ca657eb93a0cd1c735.zip cpython-225a099fe500f4c3577b60ca657eb93a0cd1c735.tar.gz cpython-225a099fe500f4c3577b60ca657eb93a0cd1c735.tar.bz2 |
unittest.TestCase uses safe_repr for producing failure messages. Partial fix for issue 7956
Diffstat (limited to 'Lib/unittest/util.py')
-rw-r--r-- | Lib/unittest/util.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/unittest/util.py b/Lib/unittest/util.py index 2546e20..9fce625 100644 --- a/Lib/unittest/util.py +++ b/Lib/unittest/util.py @@ -1,5 +1,11 @@ """Various utility functions.""" +def safe_repr(obj): + try: + return repr(obj) + except Exception: + return object.__repr__(obj) + def strclass(cls): return "%s.%s" % (cls.__module__, cls.__name__) |