diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-06-30 21:37:47 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-06-30 21:37:47 (GMT) |
commit | f87289bb58e71f5df73cbd594cbc0c0515e91c4b (patch) | |
tree | 0ab9487f6c843687835426960fab5e3eb6316eae /Lib/test/test_pep3151.py | |
parent | 4c99071c9be1cf81e915ebfcb17dcf50c6e489d6 (diff) | |
download | cpython-f87289bb58e71f5df73cbd594cbc0c0515e91c4b.zip cpython-f87289bb58e71f5df73cbd594cbc0c0515e91c4b.tar.gz cpython-f87289bb58e71f5df73cbd594cbc0c0515e91c4b.tar.bz2 |
Issue #15229: An OSError subclass whose __init__ doesn't call back
OSError.__init__ could produce incomplete instances, leading to crashes
when calling str() on them.
Diffstat (limited to 'Lib/test/test_pep3151.py')
-rw-r--r-- | Lib/test/test_pep3151.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_pep3151.py b/Lib/test/test_pep3151.py index 8af9e0c..2792c10 100644 --- a/Lib/test/test_pep3151.py +++ b/Lib/test/test_pep3151.py @@ -29,6 +29,10 @@ class SubOSErrorCombinedInitFirst(SubOSErrorWithInit, SubOSErrorWithNew): class SubOSErrorCombinedNewFirst(SubOSErrorWithNew, SubOSErrorWithInit): pass +class SubOSErrorWithStandaloneInit(OSError): + def __init__(self): + pass + class HierarchyTest(unittest.TestCase): @@ -193,6 +197,12 @@ class ExplicitSubclassingTest(unittest.TestCase): self.assertEqual(e.baz, "baz") self.assertEqual(e.args, ("some message",)) + def test_init_standalone(self): + # __init__ doesn't propagate to OSError.__init__ (see issue #15229) + e = SubOSErrorWithStandaloneInit() + self.assertEqual(e.args, ()) + self.assertEqual(str(e), '') + def test_main(): support.run_unittest(__name__) |