summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-09-28 04:45:28 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-09-28 04:45:28 (GMT)
commit4cda01e260b65dce2d9da73c45df1ecdcf4a798a (patch)
treee680c968b5f39e45726719762a6216925bee1f28 /Modules
parentaec3c9b54fe2cbd8f4b04b6034341d333bc3936b (diff)
downloadcpython-4cda01e260b65dce2d9da73c45df1ecdcf4a798a.zip
cpython-4cda01e260b65dce2d9da73c45df1ecdcf4a798a.tar.gz
cpython-4cda01e260b65dce2d9da73c45df1ecdcf4a798a.tar.bz2
* Increase test coverage.
* Have groupby() be careful about decreffing structure members.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/itertoolsmodule.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index bf2c493..3da0258 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -75,7 +75,7 @@ groupby_traverse(groupbyobject *gbo, visitproc visit, void *arg)
static PyObject *
groupby_next(groupbyobject *gbo)
{
- PyObject *newvalue, *newkey, *r, *grouper;
+ PyObject *newvalue, *newkey, *r, *grouper, *tmp;
/* skip to next iteration group */
for (;;) {
@@ -110,15 +110,19 @@ groupby_next(groupbyobject *gbo)
}
}
- Py_XDECREF(gbo->currkey);
+ tmp = gbo->currkey;
gbo->currkey = newkey;
- Py_XDECREF(gbo->currvalue);
+ Py_XDECREF(tmp);
+
+ tmp = gbo->currvalue;
gbo->currvalue = newvalue;
+ Py_XDECREF(tmp);
}
- Py_XDECREF(gbo->tgtkey);
- gbo->tgtkey = gbo->currkey;
Py_INCREF(gbo->currkey);
+ tmp = gbo->tgtkey;
+ gbo->tgtkey = gbo->currkey;
+ Py_XDECREF(tmp);
grouper = _grouper_create(gbo, gbo->tgtkey);
if (grouper == NULL)