self.assertRaises(ValueError, f.readinto1, bytearray(1024))
self.assertRaises(ValueError, f.readline)
self.assertRaises(ValueError, f.readlines)
+ self.assertRaises(ValueError, f.readlines, 1)
self.assertRaises(ValueError, f.seek, 0)
self.assertRaises(ValueError, f.tell)
self.assertRaises(ValueError, f.truncate)
Library
-------
+- bpo-30068: _io._IOBase.readlines will check if it's closed first when
+ hint is present.
+
- bpo-29694: Fixed race condition in pathlib mkdir with flags
parents=True. Patch by Armin Rigo.
-- bpo-29692: Fixed arbitrary unchaining of RuntimeError exceptions in
- contextlib.contextmanager.
- Patch by Siddharth Velankar.
+- bpo-29692: Fixed arbitrary unchaining of RuntimeError exceptions in
+ contextlib.contextmanager. Patch by Siddharth Velankar.
- bpo-29998: Pickling and copying ImportError now preserves name and path
attributes.
/*[clinic end generated code: output=2f50421677fa3dea input=1961c4a95e96e661]*/
{
Py_ssize_t length = 0;
- PyObject *result;
+ PyObject *result, *it = NULL;
result = PyList_New(0);
if (result == NULL)
PyObject *ret = _PyObject_CallMethodId(result, &PyId_extend, "O", self);
if (ret == NULL) {
- Py_DECREF(result);
- return NULL;
+ goto error;
}
Py_DECREF(ret);
return result;
}
+ it = PyObject_GetIter(self);
+ if (it == NULL) {
+ goto error;
+ }
+
while (1) {
- PyObject *line = PyIter_Next(self);
+ PyObject *line = PyIter_Next(it);
if (line == NULL) {
if (PyErr_Occurred()) {
- Py_DECREF(result);
- return NULL;
+ goto error;
}
else
break; /* StopIteration raised */
if (PyList_Append(result, line) < 0) {
Py_DECREF(line);
- Py_DECREF(result);
- return NULL;
+ goto error;
}
length += PyObject_Size(line);
Py_DECREF(line);
if (length > hint)
break;
}
+
+ Py_DECREF(it);
return result;
+
+ error:
+ Py_XDECREF(it);
+ Py_DECREF(result);
+ return NULL;
}
/*[clinic input]