mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
catch nasty exception classes with __new__ that doesn't return a exception (closes #11627)
Patch from Andreas Stührk.
This commit is contained in:
parent
1f0ccfa853
commit
5afa03a72e
3 changed files with 19 additions and 0 deletions
|
@ -121,6 +121,15 @@ class TestRaise(unittest.TestCase):
|
|||
else:
|
||||
self.fail("No exception raised")
|
||||
|
||||
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
|
||||
|
||||
|
||||
class TestCause(unittest.TestCase):
|
||||
def test_invalid_cause(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue