cpython (merge default -> default): null merge

http://hg.python.org/cpython/rev/a3b3e60f36a5 changeset: 77897:a3b3e60f36a5 parent: 77896:989efaab9525 parent: 77894:1cbab581bf1e user: doko@ubuntu.com date: Sun Jul 01 00:38:34 2012 +0200 summary: null merge files: Lib/test/test_pep3151.py | 10 ++++++++++ Misc/NEWS | 3 +++ Objects/exceptions.c | 6 ++++++ 3 files changed, 19 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_pep3151.py b/Lib/test/test_pep3151.py --- a/Lib/test/test_pep3151.py +++ b/Lib/test/test_pep3151.py @@ -29,6 +29,10 @@ class SubOSErrorCombinedNewFirst(SubOSErrorWithNew, SubOSErrorWithInit): pass +class SubOSErrorWithStandaloneInit(OSError): + def __init__(self): + pass + class HierarchyTest(unittest.TestCase): @@ -193,6 +197,12 @@ 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__) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ 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 ------- diff --git a/Objects/exceptions.c b/Objects/exceptions.c --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -834,6 +834,7 @@ #endif /* Steals the reference to args */ + Py_CLEAR(self->args); self->args = args; args = NULL; @@ -916,6 +917,11 @@ )) goto error; } + else { + self->args = PyTuple_New(0); + if (self->args == NULL) + goto error; + } return (PyObject *) self; -- Repository URL: http://hg.python.org/cpython
participants (1)
-
matthias.klose