class SubOSErrorCombinedNewFirst(SubOSErrorWithNew, SubOSErrorWithInit):
pass
+class SubOSErrorWithStandaloneInit(OSError):
+ def __init__(self):
+ pass
+
class HierarchyTest(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__)
Core and Builtins
-----------------
+- 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.
Library
-------
#endif
/* Steals the reference to args */
+ Py_CLEAR(self->args);
self->args = args;
args = NULL;
))
goto error;
}
+ else {
+ self->args = PyTuple_New(0);
+ if (self->args == NULL)
+ goto error;
+ }
return (PyObject *) self;