mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
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.
This commit is contained in:
parent
46add98758
commit
4b8c0f6d7d
1 changed files with 5 additions and 2 deletions
|
@ -146,7 +146,10 @@ tupledealloc(register PyTupleObject *op)
|
||||||
while (--i >= 0)
|
while (--i >= 0)
|
||||||
Py_XDECREF(op->ob_item[i]);
|
Py_XDECREF(op->ob_item[i]);
|
||||||
#if MAXSAVESIZE > 0
|
#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];
|
op->ob_item[0] = (PyObject *) free_tuples[len];
|
||||||
num_free_tuples[len]++;
|
num_free_tuples[len]++;
|
||||||
free_tuples[len] = op;
|
free_tuples[len] = op;
|
||||||
|
@ -594,7 +597,7 @@ _PyTuple_Resize(PyObject **pv, int newsize)
|
||||||
int sizediff;
|
int sizediff;
|
||||||
|
|
||||||
v = (PyTupleObject *) *pv;
|
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)) {
|
(v->ob_size != 0 && v->ob_refcnt != 1)) {
|
||||||
*pv = 0;
|
*pv = 0;
|
||||||
Py_XDECREF(v);
|
Py_XDECREF(v);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue