mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
Bug #1531405, format_exception no longer raises an exception if
str(exception) raised an exception.
This commit is contained in:
parent
4b8bd31ef0
commit
ff4b63b80f
3 changed files with 51 additions and 5 deletions
|
@ -130,15 +130,24 @@ def test():
|
|||
def test_string_exception1(self):
|
||||
str_type = "String Exception"
|
||||
err = traceback.format_exception_only(str_type, None)
|
||||
self.assert_(len(err) == 1)
|
||||
self.assert_(err[0] == str_type + '\n')
|
||||
self.assertEqual(len(err), 1)
|
||||
self.assertEqual(err[0], str_type + '\n')
|
||||
|
||||
def test_string_exception2(self):
|
||||
str_type = "String Exception"
|
||||
str_value = "String Value"
|
||||
err = traceback.format_exception_only(str_type, str_value)
|
||||
self.assert_(len(err) == 1)
|
||||
self.assert_(err[0] == str_type + ': ' + str_value + '\n')
|
||||
self.assertEqual(len(err), 1)
|
||||
self.assertEqual(err[0], str_type + ': ' + str_value + '\n')
|
||||
|
||||
def test_format_exception_only_bad__str__(self):
|
||||
class X(Exception):
|
||||
def __str__(self):
|
||||
1/0
|
||||
err = traceback.format_exception_only(X, X())
|
||||
self.assertEqual(len(err), 1)
|
||||
str_value = '<unprintable %s object>' % X.__name__
|
||||
self.assertEqual(err[0], X.__name__ + ': ' + str_value + '\n')
|
||||
|
||||
|
||||
def test_main():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue