[Python-checkins] r70204 - in python/branches/release30-maint: Lib/test/test_array.py Misc/NEWS Modules/arraymodule.c
hirokazu.yamamoto
python-checkins at python.org
Fri Mar 6 04:19:56 CET 2009
Author: hirokazu.yamamoto
Date: Fri Mar 6 04:19:56 2009
New Revision: 70204
Log:
Merged revisions 70203 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r70203 | hirokazu.yamamoto | 2009年03月06日 12:04:07 +0900 | 2 lines
Issue #5334: array.fromfile() failed to insert values when EOFError was raised.
Reviewed by Benjamin Peterson.
........
Modified:
python/branches/release30-maint/ (props changed)
python/branches/release30-maint/Lib/test/test_array.py
python/branches/release30-maint/Misc/NEWS
python/branches/release30-maint/Modules/arraymodule.c
Modified: python/branches/release30-maint/Lib/test/test_array.py
==============================================================================
--- python/branches/release30-maint/Lib/test/test_array.py (original)
+++ python/branches/release30-maint/Lib/test/test_array.py Fri Mar 6 04:19:56 2009
@@ -174,9 +174,8 @@
b.fromfile(f, len(self.example))
self.assertEqual(b, array.array(self.typecode, self.example))
self.assertNotEqual(a, b)
- b.fromfile(f, len(self.example))
+ self.assertRaises(EOFError, b.fromfile, f, len(self.example)+1)
self.assertEqual(a, b)
- self.assertRaises(EOFError, b.fromfile, f, 1)
f.close()
finally:
if not f.closed:
Modified: python/branches/release30-maint/Misc/NEWS
==============================================================================
--- python/branches/release30-maint/Misc/NEWS (original)
+++ python/branches/release30-maint/Misc/NEWS Fri Mar 6 04:19:56 2009
@@ -149,6 +149,8 @@
Library
-------
+- Issue #5334: array.fromfile() failed to insert values when EOFError was raised.
+
- Issue #5385: Fixed mmap crash after resize failure on windows.
- Issue #1733986: Fixed mmap crash in accessing elements of second map object
Modified: python/branches/release30-maint/Modules/arraymodule.c
==============================================================================
--- python/branches/release30-maint/Modules/arraymodule.c (original)
+++ python/branches/release30-maint/Modules/arraymodule.c Fri Mar 6 04:19:56 2009
@@ -1201,6 +1201,7 @@
PyObject *f, *b, *res;
Py_ssize_t itemsize = self->ob_descr->itemsize;
Py_ssize_t n, nbytes;
+ int not_enough_bytes;
if (!PyArg_ParseTuple(args, "On:fromfile", &f, &n))
return NULL;
@@ -1222,12 +1223,7 @@
return NULL;
}
- if (PyBytes_GET_SIZE(b) != nbytes) {
- PyErr_SetString(PyExc_EOFError,
- "read() didn't return enough bytes");
- Py_DECREF(b);
- return NULL;
- }
+ not_enough_bytes = (PyBytes_GET_SIZE(b) != nbytes);
args = Py_BuildValue("(O)", b);
Py_DECREF(b);
@@ -1236,6 +1232,15 @@
res = array_fromstring(self, args);
Py_DECREF(args);
+ if (res == NULL)
+ return NULL;
+
+ if (not_enough_bytes) {
+ PyErr_SetString(PyExc_EOFError,
+ "read() didn't return enough bytes");
+ Py_DECREF(res);
+ return NULL;
+ }
return res;
}
More information about the Python-checkins
mailing list