summaryrefslogtreecommitdiffstats
path: root/pym/_emerge/AbstractPollTask.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-12-16 11:32:39 -0800
committerZac Medico <zmedico@gentoo.org>2011-12-16 11:32:39 -0800
commitf1ec68632ff22b72b25c0d70cc2f2c137f957a91 (patch)
treedb4e284be61464f9d129c88ff16c4e7b2466f56e /pym/_emerge/AbstractPollTask.py
parentf75fc7375ea902da2e96825ca27c8b7f5031a491 (diff)
downloadportage-f1ec68632ff22b72b25c0d70cc2f2c137f957a91.tar.gz
portage-f1ec68632ff22b72b25c0d70cc2f2c137f957a91.tar.bz2
portage-f1ec68632ff22b72b25c0d70cc2f2c137f957a91.zip
SpawnProcess/AbstractPollTask: eliminate array
Since commit 30d2d0a9db486c5a70848ad5d27b37a3ec48f271, we use os.read() due to bugs in array.fromfile(). So, eliminate array usage entirely.
Diffstat (limited to 'pym/_emerge/AbstractPollTask.py')
-rw-r--r--pym/_emerge/AbstractPollTask.py20
1 files changed, 6 insertions, 14 deletions
diff --git a/pym/_emerge/AbstractPollTask.py b/pym/_emerge/AbstractPollTask.py
index d4785a2a1..b3c0b2d16 100644
--- a/pym/_emerge/AbstractPollTask.py
+++ b/pym/_emerge/AbstractPollTask.py
@@ -1,7 +1,6 @@
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-import array
import errno
import logging
import os
@@ -27,10 +26,9 @@ class AbstractPollTask(AsynchronousTask):
| POLLIN | RETURN
| BIT | VALUE
| ---------------------------------------------------
- | 1 | Read self._bufsize into an instance of
- | | array.array('B') and return it, ignoring
- | | EOFError and IOError. An empty array
- | | indicates EOF.
+ | 1 | Read self._bufsize into a string of bytes,
+ | | handling EAGAIN and EIO. An empty string
+ | | of bytes indicates EOF.
| ---------------------------------------------------
| 0 | None
"""
@@ -39,20 +37,14 @@ class AbstractPollTask(AsynchronousTask):
# and Python 3.2).
buf = None
if event & PollConstants.POLLIN:
- buf = array.array('B')
try:
- # Python >=3.2
- frombytes = buf.frombytes
- except AttributeError:
- frombytes = buf.fromstring
- try:
- frombytes(os.read(fd, self._bufsize))
+ buf = os.read(fd, self._bufsize)
except OSError as e:
# EIO happens with pty on Linux after the
# slave end of the pty has been closed.
if e.errno == errno.EIO:
- # EOF: return empty buffer
- pass
+ # EOF: return empty string of bytes
+ buf = b''
elif e.errno == errno.EAGAIN:
# EAGAIN: return None
buf = None