Bug #330937: Handle IOError raised by remaining calls to array.fromfile().
authorArfrever Frehtes Taifersar Arahesis <Arfrever@Gentoo.Org>
Thu, 5 Aug 2010 13:02:20 +0000 (15:02 +0200)
committerArfrever Frehtes Taifersar Arahesis <Arfrever@Gentoo.Org>
Thu, 5 Aug 2010 13:02:20 +0000 (15:02 +0200)
pym/_emerge/PipeReader.py
pym/_emerge/SpawnProcess.py
pym/portage/package/ebuild/doebuild.py
pym/portage/tests/ebuild/test_array_fromfile_eof.py
pym/portage/util/_pty.py

index be958bcb224a1aac03e944e2460297c2a5f4dbd0..2c3495c37d4370cefb46478ce66b701beac79715 100644 (file)
@@ -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:
index bacbc2f30faf50b5ce1b81a343826d4af39fc56e..490b111f7cfb97c272a91ceb4da449367bbaaafd 100644 (file)
@@ -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:
index b9cbc3e0e766d1a5d2a3b31ca627c3caebe362ba..c8ec3fc23c9057166c7b312f41ab7e8fa26e3f3a 100644 (file)
@@ -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
index 3f2a6c7c5fb404ca02c50f9b789a3be3f1b286c0..c32a15cb009839633da734636b8f6151459a3543 100644 (file)
@@ -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
 
index 7fba0e2baec9c95c911f0063075e4254953664a9..a4910ec7057ac61e3340fde06b53936e17693549 100644 (file)
@@ -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: