diff options
author | Guido van Rossum <guido@python.org> | 2001-08-30 18:31:30 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-08-30 18:31:30 (GMT) |
commit | 4b8c0f6d7d66e2ca8f3a80d1b9ba01afee88f574 (patch) | |
tree | 600ddf2544474c413102eb25b68c163c10b3be26 | |
parent | 46add98758415f6180532326571d73f22966c34e (diff) | |
download | cpython-4b8c0f6d7d66e2ca8f3a80d1b9ba01afee88f574.zip cpython-4b8c0f6d7d66e2ca8f3a80d1b9ba01afee88f574.tar.gz cpython-4b8c0f6d7d66e2ca8f3a80d1b9ba01afee88f574.tar.bz2 |
More stuff discovered while writing the simplest of testcases:
tupledealloc(): only feed the free list when the type is really a
tuple, not a subtype. Otherwise, use PyObject_GC_Del().
_PyTuple_Resize(): disallow using this for tuple subtypes.
-rw-r--r-- | Objects/tupleobject.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 9ae732f..6401dca 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -146,7 +146,10 @@ tupledealloc(register PyTupleObject *op) while (--i >= 0) Py_XDECREF(op->ob_item[i]); #if MAXSAVESIZE > 0 - if (len < MAXSAVESIZE && num_free_tuples[len] < MAXSAVEDTUPLES) { + if (len < MAXSAVESIZE && + num_free_tuples[len] < MAXSAVEDTUPLES && + op->ob_type == &PyTuple_Type) + { op->ob_item[0] = (PyObject *) free_tuples[len]; num_free_tuples[len]++; free_tuples[len] = op; @@ -594,7 +597,7 @@ _PyTuple_Resize(PyObject **pv, int newsize) int sizediff; v = (PyTupleObject *) *pv; - if (v == NULL || !PyTuple_Check(v) || + if (v == NULL || v->ob_type != &PyTuple_Type || (v->ob_size != 0 && v->ob_refcnt != 1)) { *pv = 0; Py_XDECREF(v); |