[Python-checkins] r51722 - in python/branches/release25-maint: Lib/test/test_itertools.py Misc/NEWS Modules/itertoolsmodule.c
neal.norwitz
python-checkins at python.org
Tue Sep 5 04:30:10 CEST 2006
Author: neal.norwitz
Date: Tue Sep 5 04:30:10 2006
New Revision: 51722
Modified:
python/branches/release25-maint/Lib/test/test_itertools.py
python/branches/release25-maint/Misc/NEWS
python/branches/release25-maint/Modules/itertoolsmodule.c
Log:
Backport fix for SF bug #1550714, itertools.tee raises SystemError
Modified: python/branches/release25-maint/Lib/test/test_itertools.py
==============================================================================
--- python/branches/release25-maint/Lib/test/test_itertools.py (original)
+++ python/branches/release25-maint/Lib/test/test_itertools.py Tue Sep 5 04:30:10 2006
@@ -371,6 +371,7 @@
# test values of n
self.assertRaises(TypeError, tee, 'abc', 'invalid')
+ self.assertRaises(ValueError, tee, [], -1)
for n in xrange(5):
result = tee('abc', n)
self.assertEqual(type(result), tuple)
Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS (original)
+++ python/branches/release25-maint/Misc/NEWS Tue Sep 5 04:30:10 2006
@@ -43,6 +43,12 @@
- Bug #1543303, patch #1543897: remove NUL padding from tarfiles.
+Extension Modules
+-----------------
+
+- Bug #1550714: fix SystemError from itertools.tee on negative value for n.
+
+
Tests
-----
Modified: python/branches/release25-maint/Modules/itertoolsmodule.c
==============================================================================
--- python/branches/release25-maint/Modules/itertoolsmodule.c (original)
+++ python/branches/release25-maint/Modules/itertoolsmodule.c Tue Sep 5 04:30:10 2006
@@ -618,11 +618,15 @@
static PyObject *
tee(PyObject *self, PyObject *args)
{
- int i, n=2;
+ Py_ssize_t i, n=2;
PyObject *it, *iterable, *copyable, *result;
- if (!PyArg_ParseTuple(args, "O|i", &iterable, &n))
+ if (!PyArg_ParseTuple(args, "O|n", &iterable, &n))
return NULL;
+ if (n < 0) {
+ PyErr_SetString(PyExc_ValueError, "n must be >= 0");
+ return NULL;
+ }
result = PyTuple_New(n);
if (result == NULL)
return NULL;
More information about the Python-checkins
mailing list