mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Repair refcounting on error return from type_set_bases.
Include a test case that failed for one of my efforts to repair this.
This commit is contained in:
parent
bb18f620ad
commit
e723e453a1
2 changed files with 13 additions and 3 deletions
|
@ -3585,6 +3585,13 @@ def test_mutable_bases():
|
||||||
# actually, we'll have crashed by here...
|
# actually, we'll have crashed by here...
|
||||||
raise TestFailed, "shouldn't be able to create inheritance cycles"
|
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:
|
try:
|
||||||
D.__bases__ = (E,)
|
D.__bases__ = (E,)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
|
|
|
@ -303,13 +303,16 @@ type_set_bases(PyTypeObject *type, PyObject *value, void *context)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
bail:
|
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_bases = old_bases;
|
||||||
type->tp_base = old_base;
|
type->tp_base = old_base;
|
||||||
type->tp_mro = old_mro;
|
type->tp_mro = old_mro;
|
||||||
|
|
||||||
Py_DECREF(value);
|
|
||||||
Py_DECREF(new_base);
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue