From: Michael W. Hudson Date: Thu, 7 Aug 2003 15:08:55 +0000 (+0000) Subject: As penance for forgetting to flag my last checkins as bugfix candidates, X-Git-Tag: v2.3.1~179 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=40b4a6b015a1902206a8b4bcc0620a5c36f29dbc;p=thirdparty%2FPython%2Fcpython.git As penance for forgetting to flag my last checkins as bugfix candidates, just do the backport. These changes do not apply to release22-maint. --- diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index cb13ff2e065a..b3336d1fc8d7 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -3585,6 +3585,13 @@ def test_mutable_bases(): # actually, we'll have crashed by here... raise TestFailed, "shouldn't be able to create inheritance cycles" + try: + D.__bases__ = (C, C) + except TypeError: + pass + else: + raise TestFailed, "didn't detect repeated base classes" + try: D.__bases__ = (E,) except TypeError: diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 60c4fbc6d10d..2a7df8aa6326 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -303,13 +303,16 @@ type_set_bases(PyTypeObject *type, PyObject *value, void *context) return r; bail: + Py_DECREF(type->tp_bases); + Py_DECREF(type->tp_base); + if (type->tp_mro != old_mro) { + Py_DECREF(type->tp_mro); + } + type->tp_bases = old_bases; type->tp_base = old_base; type->tp_mro = old_mro; - Py_DECREF(value); - Py_DECREF(new_base); - return -1; }