mirror of
https://github.com/python/cpython.git
synced 2025-08-02 08:02:56 +00:00
returns in cStringIO.c. Thanks to Andrew Bennetts. This must be a backport candidate.
This commit is contained in:
parent
19e11c86a7
commit
10402a306f
4 changed files with 26 additions and 7 deletions
|
@ -44,6 +44,13 @@ class TestGenericStringIO(unittest.TestCase):
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
self.assertEqual(f.getvalue(), 'abc')
|
self.assertEqual(f.getvalue(), 'abc')
|
||||||
|
|
||||||
|
def test_writelines_error(self):
|
||||||
|
def errorGen():
|
||||||
|
yield 'a'
|
||||||
|
raise KeyboardInterrupt()
|
||||||
|
f = self.MODULE.StringIO()
|
||||||
|
self.assertRaises(KeyboardInterrupt, f.writelines, errorGen())
|
||||||
|
|
||||||
def test_truncate(self):
|
def test_truncate(self):
|
||||||
eq = self.assertEqual
|
eq = self.assertEqual
|
||||||
f = self.MODULE.StringIO()
|
f = self.MODULE.StringIO()
|
||||||
|
|
|
@ -50,6 +50,7 @@ Reimer Behrends
|
||||||
Thomas Bellman
|
Thomas Bellman
|
||||||
Juan M. Bello Rivas
|
Juan M. Bello Rivas
|
||||||
Alexander Belopolsky
|
Alexander Belopolsky
|
||||||
|
Andrew Bennetts
|
||||||
Andy Bensky
|
Andy Bensky
|
||||||
Michel Van den Bergh
|
Michel Van den Bergh
|
||||||
Eric Beser
|
Eric Beser
|
||||||
|
|
|
@ -149,6 +149,9 @@ present).
|
||||||
Extension Modules
|
Extension Modules
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Patches #1298449 and #1298499: Add some missing checks for error
|
||||||
|
returns in cStringIO.c.
|
||||||
|
|
||||||
- Patch #1297028: fix segfault if call type on MultibyteCodec,
|
- Patch #1297028: fix segfault if call type on MultibyteCodec,
|
||||||
MultibyteStreamReader, or MultibyteStreamWriter
|
MultibyteStreamReader, or MultibyteStreamWriter
|
||||||
|
|
||||||
|
|
|
@ -241,7 +241,10 @@ IO_readlines(IOobject *self, PyObject *args) {
|
||||||
line = PyString_FromStringAndSize (output, n);
|
line = PyString_FromStringAndSize (output, n);
|
||||||
if (!line)
|
if (!line)
|
||||||
goto err;
|
goto err;
|
||||||
PyList_Append (result, line);
|
if (PyList_Append (result, line) == -1) {
|
||||||
|
Py_DECREF (line);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
Py_DECREF (line);
|
Py_DECREF (line);
|
||||||
length += n;
|
length += n;
|
||||||
if (hint > 0 && length >= hint)
|
if (hint > 0 && length >= hint)
|
||||||
|
@ -440,13 +443,18 @@ O_writelines(Oobject *self, PyObject *args) {
|
||||||
Py_DECREF(it);
|
Py_DECREF(it);
|
||||||
Py_DECREF(s);
|
Py_DECREF(s);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
Py_DECREF(s);
|
Py_DECREF(s);
|
||||||
}
|
}
|
||||||
Py_DECREF(it);
|
|
||||||
Py_RETURN_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Py_DECREF(it);
|
||||||
|
|
||||||
|
/* See if PyIter_Next failed */
|
||||||
|
if (PyErr_Occurred())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
}
|
||||||
static struct PyMethodDef O_methods[] = {
|
static struct PyMethodDef O_methods[] = {
|
||||||
/* Common methods: */
|
/* Common methods: */
|
||||||
{"flush", (PyCFunction)IO_flush, METH_NOARGS, IO_flush__doc__},
|
{"flush", (PyCFunction)IO_flush, METH_NOARGS, IO_flush__doc__},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue