mirror of
https://github.com/python/cpython.git
synced 2025-08-15 22:30:42 +00:00
Merged revisions 83030 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r83030 | antoine.pitrou | 2010-07-21 18:41:31 +0200 (mer., 21 juil. 2010) | 5 lines Issue #5395: check that array.fromfile() re-raises an IOError instead of replacing it with EOFError. (this is only an added test, but 2.x will get a fix too) ........
This commit is contained in:
parent
2f3379f978
commit
7a7013e830
4 changed files with 24 additions and 2 deletions
|
@ -188,6 +188,17 @@ class BaseTest(unittest.TestCase):
|
||||||
f.close()
|
f.close()
|
||||||
test_support.unlink(test_support.TESTFN)
|
test_support.unlink(test_support.TESTFN)
|
||||||
|
|
||||||
|
def test_fromfile_ioerror(self):
|
||||||
|
# Issue #5395: Check if fromfile raises a proper IOError
|
||||||
|
# instead of EOFError.
|
||||||
|
a = array.array(self.typecode)
|
||||||
|
f = open(test_support.TESTFN, 'wb')
|
||||||
|
try:
|
||||||
|
self.assertRaises(IOError, a.fromfile, f, len(self.example))
|
||||||
|
finally:
|
||||||
|
f.close()
|
||||||
|
test_support.unlink(test_support.TESTFN)
|
||||||
|
|
||||||
def test_filewrite(self):
|
def test_filewrite(self):
|
||||||
a = array.array(self.typecode, 2*self.example)
|
a = array.array(self.typecode, 2*self.example)
|
||||||
f = open(test_support.TESTFN, 'wb')
|
f = open(test_support.TESTFN, 'wb')
|
||||||
|
|
|
@ -355,6 +355,7 @@ Michiel de Hoon
|
||||||
Brian Hooper
|
Brian Hooper
|
||||||
Randall Hopper
|
Randall Hopper
|
||||||
Nadav Horesh
|
Nadav Horesh
|
||||||
|
Jan Hosang
|
||||||
Ken Howard
|
Ken Howard
|
||||||
Brad Howes
|
Brad Howes
|
||||||
Chih-Hao Huang
|
Chih-Hao Huang
|
||||||
|
|
|
@ -18,6 +18,10 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #5395: array.fromfile() would raise a spurious EOFError when an
|
||||||
|
I/O error occurred. Now an IOError is raised instead. Patch by chuck
|
||||||
|
(Jan Hosang).
|
||||||
|
|
||||||
- Issue 1712522: urllib.quote supports Unicode String with encoding and errors
|
- Issue 1712522: urllib.quote supports Unicode String with encoding and errors
|
||||||
parameter. The encoding parameter defaults to utf-8 and errors to strict.
|
parameter. The encoding parameter defaults to utf-8 and errors to strict.
|
||||||
Patch by Matt Giuca.
|
Patch by Matt Giuca.
|
||||||
|
|
|
@ -1228,8 +1228,14 @@ array_fromfile(arrayobject *self, PyObject *args)
|
||||||
PyMem_RESIZE(item, char, Py_SIZE(self)*itemsize);
|
PyMem_RESIZE(item, char, Py_SIZE(self)*itemsize);
|
||||||
self->ob_item = item;
|
self->ob_item = item;
|
||||||
self->allocated = Py_SIZE(self);
|
self->allocated = Py_SIZE(self);
|
||||||
|
if (ferror(fp)) {
|
||||||
|
PyErr_SetFromErrno(PyExc_IOError);
|
||||||
|
clearerr(fp);
|
||||||
|
}
|
||||||
|
else {
|
||||||
PyErr_SetString(PyExc_EOFError,
|
PyErr_SetString(PyExc_EOFError,
|
||||||
"not enough items in file");
|
"not enough items in file");
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue