From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RbdWj-0001vQ-Tk for garchives@archives.gentoo.org; Fri, 16 Dec 2011 19:33:06 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 73F7B21C0B4; Fri, 16 Dec 2011 19:32:58 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 3556421C0B4 for ; Fri, 16 Dec 2011 19:32:58 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D475A1B4038 for ; Fri, 16 Dec 2011 19:32:56 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 498958004A for ; Fri, 16 Dec 2011 19:32:56 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/AbstractPollTask.py pym/_emerge/SpawnProcess.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: f1ec68632ff22b72b25c0d70cc2f2c137f957a91 Date: Fri, 16 Dec 2011 19:32:56 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 32184b31-3b74-45d0-9ef8-3a31ff1f6ffd X-Archives-Hash: 757175adf5d880011d59760e4dab9eb2 commit: f1ec68632ff22b72b25c0d70cc2f2c137f957a91 Author: Zac Medico gentoo org> AuthorDate: Fri Dec 16 19:32:39 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Fri Dec 16 19:32:39 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3Df1ec6863 SpawnProcess/AbstractPollTask: eliminate array Since commit 30d2d0a9db486c5a70848ad5d27b37a3ec48f271, we use os.read() due to bugs in array.fromfile(). So, eliminate array usage entirely. --- pym/_emerge/AbstractPollTask.py | 20 ++++++-------------- pym/_emerge/SpawnProcess.py | 13 ++----------- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/pym/_emerge/AbstractPollTask.py b/pym/_emerge/AbstractPollTa= sk.py index d4785a2..b3c0b2d 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 =20 -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 =3D None if event & PollConstants.POLLIN: - buf =3D array.array('B') try: - # Python >=3D3.2 - frombytes =3D buf.frombytes - except AttributeError: - frombytes =3D buf.fromstring - try: - frombytes(os.read(fd, self._bufsize)) + buf =3D 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 =3D=3D errno.EIO: - # EOF: return empty buffer - pass + # EOF: return empty string of bytes + buf =3D b'' elif e.errno =3D=3D errno.EAGAIN: # EAGAIN: return None buf =3D None diff --git a/pym/_emerge/SpawnProcess.py b/pym/_emerge/SpawnProcess.py index 9f83ef0..ec5bf7d 100644 --- a/pym/_emerge/SpawnProcess.py +++ b/pym/_emerge/SpawnProcess.py @@ -183,7 +183,7 @@ class SpawnProcess(SubProcess): while True: try: if not write_successful: - buf.tofile(files.stdout) + files.stdout.write(buf) write_successful =3D True files.stdout.flush() break @@ -213,16 +213,7 @@ class SpawnProcess(SubProcess): fcntl.fcntl(files.stdout.fileno(), fcntl.F_GETFL) ^ os.O_NONBLOCK) =20 - try: - buf.tofile(files.log) - except TypeError: - # array.tofile() doesn't work with GzipFile - try: - # Python >=3D3.2 - data =3D buf.tobytes() - except AttributeError: - data =3D buf.tostring() - files.log.write(data) + files.log.write(buf) files.log.flush() =20 self._unregister_if_appropriate(event)