From eb863416cde2c7b7a7ab8f70b5bac4b4fc4d8aee Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Thu, 5 Aug 2010 15:02:20 +0200 Subject: Bug #330937: Handle IOError raised by remaining calls to array.fromfile(). --- pym/_emerge/PipeReader.py | 3 ++- pym/_emerge/SpawnProcess.py | 3 ++- pym/portage/package/ebuild/doebuild.py | 3 ++- pym/portage/tests/ebuild/test_array_fromfile_eof.py | 3 ++- pym/portage/util/_pty.py | 6 ++---- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pym/_emerge/PipeReader.py b/pym/_emerge/PipeReader.py index be958bcb2..2c3495c37 100644 --- a/pym/_emerge/PipeReader.py +++ b/pym/_emerge/PipeReader.py @@ -71,7 +71,8 @@ class PipeReader(AbstractPollTask): buf = array.array('B') try: buf.fromfile(f, self._bufsize) - except EOFError: + # EOFError was raised in Python <2.6.6 and <2.7.1. + except (EOFError, IOError): pass if buf: diff --git a/pym/_emerge/SpawnProcess.py b/pym/_emerge/SpawnProcess.py index bacbc2f30..490b111f7 100644 --- a/pym/_emerge/SpawnProcess.py +++ b/pym/_emerge/SpawnProcess.py @@ -210,7 +210,8 @@ class SpawnProcess(SubProcess): buf = array.array('B') try: buf.fromfile(self._files.process, self._bufsize) - except EOFError: + # EOFError was raised in Python <2.6.6 and <2.7.1. + except (EOFError, IOError): pass if buf: diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py index b9cbc3e0e..c8ec3fc23 100644 --- a/pym/portage/package/ebuild/doebuild.py +++ b/pym/portage/package/ebuild/doebuild.py @@ -1268,7 +1268,8 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero buf = array.array('B') try: buf.fromfile(f, buffsize) - except EOFError: + # EOFError was raised in Python <2.6.6 and <2.7.1. + except (EOFError, IOError): pass if not buf: eof = True diff --git a/pym/portage/tests/ebuild/test_array_fromfile_eof.py b/pym/portage/tests/ebuild/test_array_fromfile_eof.py index 3f2a6c7c5..c32a15cb0 100644 --- a/pym/portage/tests/ebuild/test_array_fromfile_eof.py +++ b/pym/portage/tests/ebuild/test_array_fromfile_eof.py @@ -28,7 +28,8 @@ class ArrayFromfileEofTestCase(TestCase): a = array.array('B') try: a.fromfile(f, len(input_bytes) + 1) - except EOFError: + # EOFError was raised in Python <2.6.6 and <2.7.1. + except (EOFError, IOError): # python-3.0 lost data here eof = True diff --git a/pym/portage/util/_pty.py b/pym/portage/util/_pty.py index 7fba0e2ba..a4910ec70 100644 --- a/pym/portage/util/_pty.py +++ b/pym/portage/util/_pty.py @@ -95,10 +95,8 @@ def _test_pty_eof(): buf = array.array('B') try: buf.fromfile(master_file, 1024) - except EOFError: - eof = True - except IOError: - # This is where data loss occurs. + # EOFError was raised in Python <2.6.6 and <2.7.1. + except (EOFError, IOError): eof = True if not buf: -- cgit v1.2.3-1-g7c22