From 5df96179611ce0e98727945b1800b43daccedfc2 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 12 Jul 2011 01:41:09 -0700 Subject: [PATCH] Remove python-2.6 StringIO.StringIO fallback. Since the io module in python-2.6 was broken when threading was disabled, we needed to fall back from io.StringIO to StringIO.StringIO in this case (typically just for Gentoo's stage1 and stage2 tarballs). Now that python-2.7 is stable in stages and we rely on io.open() being available, we can also rely on io.StringIO being available. --- bin/repoman | 3 +-- pym/_emerge/AbstractEbuildProcess.py | 5 ++--- pym/_emerge/BinpkgVerifier.py | 3 ++- pym/_emerge/EbuildFetcher.py | 2 +- pym/_emerge/EbuildPhase.py | 10 +++++----- pym/_emerge/JobStatusDisplay.py | 8 ++++---- pym/_emerge/Scheduler.py | 1 - pym/portage/__init__.py | 8 -------- pym/portage/dbapi/_MergeProcess.py | 6 +++--- pym/portage/dbapi/vartree.py | 2 +- pym/portage/package/ebuild/_ipc/QueryCommand.py | 7 ++++--- pym/portage/util/__init__.py | 6 +++--- 12 files changed, 26 insertions(+), 35 deletions(-) diff --git a/bin/repoman b/bin/repoman index 3e0203681..f1fbc2444 100755 --- a/bin/repoman +++ b/bin/repoman @@ -55,7 +55,6 @@ from portage import os from portage import subprocess_getstatusoutput from portage import _encodings from portage import _unicode_encode -from portage import StringIO from repoman.checks import run_checks from repoman import utilities from repoman.herdbase import make_herd_base @@ -2011,7 +2010,7 @@ if dofail or \ # in $EDITOR while the user creates a commit message. # Otherwise, the user would not be able to see this output # once the editor has taken over the screen. -qa_output = StringIO() +qa_output = io.StringIO() style_file = ConsoleStyleFile(sys.stdout) if options.mode == 'commit' and \ (not commitmessage or not commitmessage.strip()): diff --git a/pym/_emerge/AbstractEbuildProcess.py b/pym/_emerge/AbstractEbuildProcess.py index 0d1d991d4..49b85eba3 100644 --- a/pym/_emerge/AbstractEbuildProcess.py +++ b/pym/_emerge/AbstractEbuildProcess.py @@ -1,7 +1,7 @@ # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -import platform +import io import stat import textwrap from _emerge.SpawnProcess import SpawnProcess @@ -13,7 +13,6 @@ from portage.localization import _ from portage.package.ebuild._ipc.ExitCommand import ExitCommand from portage.package.ebuild._ipc.QueryCommand import QueryCommand from portage import os -from portage import StringIO from portage import _encodings from portage import _unicode_decode from portage.util._pty import _create_pty_or_pipe @@ -216,7 +215,7 @@ class AbstractEbuildProcess(SpawnProcess): self._elog('eerror', lines) def _elog(self, elog_funcname, lines): - out = StringIO() + out = io.StringIO() phase = self.phase elog_func = getattr(elog_messages, elog_funcname) global_havecolor = portage.output.havecolor diff --git a/pym/_emerge/BinpkgVerifier.py b/pym/_emerge/BinpkgVerifier.py index 379c862af..91dc8a7d3 100644 --- a/pym/_emerge/BinpkgVerifier.py +++ b/pym/_emerge/BinpkgVerifier.py @@ -3,6 +3,7 @@ from _emerge.AsynchronousTask import AsynchronousTask from portage.util import writemsg +import io import sys import portage from portage import os @@ -27,7 +28,7 @@ class BinpkgVerifier(AsynchronousTask): stdout_orig = sys.stdout stderr_orig = sys.stderr global_havecolor = portage.output.havecolor - out = portage.StringIO() + out = io.StringIO() file_exists = True try: sys.stdout = out diff --git a/pym/_emerge/EbuildFetcher.py b/pym/_emerge/EbuildFetcher.py index 51d2f5a10..f67819c16 100644 --- a/pym/_emerge/EbuildFetcher.py +++ b/pym/_emerge/EbuildFetcher.py @@ -186,7 +186,7 @@ class EbuildFetcher(SpawnProcess): return (master_fd, slave_fd) def _eerror(self, lines): - out = portage.StringIO() + out = io.StringIO() for line in lines: eerror(line, phase="unpack", key=self.pkg.cpv, out=out) msg = _unicode_decode(out.getvalue(), diff --git a/pym/_emerge/EbuildPhase.py b/pym/_emerge/EbuildPhase.py index 64d33a8ca..c7f5b8827 100644 --- a/pym/_emerge/EbuildPhase.py +++ b/pym/_emerge/EbuildPhase.py @@ -2,6 +2,7 @@ # Distributed under the terms of the GNU General Public License v2 import gzip +import io import sys import tempfile @@ -23,7 +24,6 @@ portage.proxy.lazyimport.lazyimport(globals(), '_preinst_bsdflags' ) from portage import os -from portage import StringIO from portage import _encodings from portage import _unicode_decode from portage import _unicode_encode @@ -191,7 +191,7 @@ class EbuildPhase(CompositeTask): logfile = self.settings.get("PORTAGE_LOG_FILE") if self.phase == "install": - out = portage.StringIO() + out = io.StringIO() _check_build_log(self.settings, out=out) msg = _unicode_decode(out.getvalue(), encoding=_encodings['content'], errors='replace') @@ -205,7 +205,7 @@ class EbuildPhase(CompositeTask): _post_phase_userpriv_perms(settings) if self.phase == "install": - out = portage.StringIO() + out = io.StringIO() _post_src_install_chost_fix(settings) _post_src_install_uid_fix(settings, out) msg = _unicode_decode(out.getvalue(), @@ -261,7 +261,7 @@ class EbuildPhase(CompositeTask): return if self.phase == "install": - out = portage.StringIO() + out = io.StringIO() _post_src_install_soname_symlinks(self.settings, out) msg = _unicode_decode(out.getvalue(), encoding=_encodings['content'], errors='replace') @@ -333,7 +333,7 @@ class EbuildPhase(CompositeTask): def _elog(self, elog_funcname, lines, background=None): if background is None: background = self.background - out = StringIO() + out = io.StringIO() phase = self.phase elog_func = getattr(elog_messages, elog_funcname) global_havecolor = portage.output.havecolor diff --git a/pym/_emerge/JobStatusDisplay.py b/pym/_emerge/JobStatusDisplay.py index d3d330d30..1949232e7 100644 --- a/pym/_emerge/JobStatusDisplay.py +++ b/pym/_emerge/JobStatusDisplay.py @@ -1,12 +1,12 @@ -# Copyright 1999-2009 Gentoo Foundation +# Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import formatter +import io import sys import time import portage -from portage import StringIO from portage import os from portage import _encodings from portage import _unicode_decode @@ -237,8 +237,8 @@ class JobStatusDisplay(object): failed_str = str(self.failed) load_avg_str = self._load_avg_str() - color_output = StringIO() - plain_output = StringIO() + color_output = io.StringIO() + plain_output = io.StringIO() style_file = portage.output.ConsoleStyleFile(color_output) style_file.write_listener = plain_output style_writer = portage.output.StyleWriter(file=style_file, maxcol=9999) diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index b88e2c29b..ad276e9bc 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -18,7 +18,6 @@ import weakref import zlib import portage -from portage import StringIO from portage import os from portage import _encodings from portage import _unicode_decode, _unicode_encode diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 38da8a0b2..5411ec921 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -22,14 +22,6 @@ try: except ImportError: from commands import getstatusoutput as subprocess_getstatusoutput - try: - from io import StringIO - except ImportError: - # Needed for python-2.6 with USE=build since - # io imports threading which imports thread - # which is unavailable. - from StringIO import StringIO - import platform # Temporarily delete these imports, to ensure that only the diff --git a/pym/portage/dbapi/_MergeProcess.py b/pym/portage/dbapi/_MergeProcess.py index 3b9ad8284..34ed03157 100644 --- a/pym/portage/dbapi/_MergeProcess.py +++ b/pym/portage/dbapi/_MergeProcess.py @@ -1,16 +1,16 @@ # Copyright 2010-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +import io import shutil import signal -import sys import tempfile import traceback import errno import fcntl import portage -from portage import os, StringIO, _unicode_decode +from portage import os, _unicode_decode from portage.const import PORTAGE_PACKAGE_ATOM from portage.dep import match_from_list import portage.elog.messages @@ -134,7 +134,7 @@ class MergeProcess(SpawnProcess): else: lines[0] = self._buf + lines[0] self._buf = lines.pop() - out = StringIO() + out = io.StringIO() for line in lines: funcname, phase, key, msg = line.split(' ', 3) self._elog_keys.add(key) diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index d5c055420..bec3d6629 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -2925,7 +2925,7 @@ class dblink(object): log_path = None if self.settings.get("PORTAGE_BACKGROUND") != "subprocess": log_path = self.settings.get("PORTAGE_LOG_FILE") - out = portage.StringIO() + out = io.StringIO() for line in lines: func(line, phase=phase, key=self.mycpv, out=out) msg = out.getvalue() diff --git a/pym/portage/package/ebuild/_ipc/QueryCommand.py b/pym/portage/package/ebuild/_ipc/QueryCommand.py index 7d006acf0..5e1533f99 100644 --- a/pym/portage/package/ebuild/_ipc/QueryCommand.py +++ b/pym/portage/package/ebuild/_ipc/QueryCommand.py @@ -1,9 +1,10 @@ -# Copyright 2010 Gentoo Foundation +# Copyright 2010-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +import io + import portage from portage import os -from portage import StringIO from portage import _encodings from portage import _unicode_decode from portage.dep import Atom @@ -83,7 +84,7 @@ class QueryCommand(IpcCommand): don't want to corrupt it, especially if it is being written with compression. """ - out = StringIO() + out = io.StringIO() phase = self.phase elog_func = getattr(elog_messages, elog_funcname) global_havecolor = portage.output.havecolor diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py index b641d3ed2..4aa63d5e3 100644 --- a/pym/portage/util/__init__.py +++ b/pym/portage/util/__init__.py @@ -32,7 +32,7 @@ portage.proxy.lazyimport.lazyimport(globals(), 'portage.dep:Atom', 'portage.util.listdir:_ignorecvs_dirs' ) -from portage import StringIO + from portage import os from portage import subprocess_getstatusoutput from portage import _encodings @@ -63,7 +63,7 @@ def writemsg(mystr,noiselevel=0,fd=None): fd = sys.stderr if noiselevel <= noiselimit: # avoid potential UnicodeEncodeError - if isinstance(fd, StringIO): + if isinstance(fd, io.StringIO): mystr = _unicode_decode(mystr, encoding=_encodings['content'], errors='replace') else: @@ -521,7 +521,7 @@ class _tolerant_shlex(shlex.shlex): except EnvironmentError as e: writemsg(_("!!! Parse error in '%s': source command failed: %s\n") % \ (self.infile, str(e)), noiselevel=-1) - return (newfile, StringIO()) + return (newfile, io.StringIO()) _invalid_var_name_re = re.compile(r'^\d|\W') -- 2.26.2