port 8d05f697acd4 (#11627)

This commit is contained in:
Benjamin Peterson 2011-07-15 14:15:40 -05:00
parent 2659140a5d
commit c3349cd22e
3 changed files with 21 additions and 2 deletions

View file

@ -464,6 +464,14 @@ class ExceptionTests(unittest.TestCase):
self.assertTrue(e is RuntimeError, e)
self.assertIn("maximum recursion depth exceeded", str(v))
def test_new_returns_invalid_instance(self):
# See issue #11627.
class MyException(Exception):
def __new__(cls, *args):
return object()
with self.assertRaises(TypeError):
raise MyException
# Helper class used by TestSameStrAndUnicodeMsg