From 59ed24dd2ff8f0a2c2c6d921035a1a042c6c8e3f Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 21 Jan 2011 16:50:59 -0800 Subject: fdopen: read from processes in unbuffered mode It doesn't make sense to use buffers in cases like this, and is potentially error prone (as in bug #287648 / python issue 5380). --- pym/_emerge/EbuildMetadataPhase.py | 4 ++-- pym/portage/package/ebuild/doebuild.py | 2 +- pym/portage/tests/lazyimport/test_lazy_import_portage_baseline.py | 4 ++-- pym/portage/tests/process/test_poll.py | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pym/_emerge/EbuildMetadataPhase.py b/pym/_emerge/EbuildMetadataPhase.py index eaa7f40b2..5925ec462 100644 --- a/pym/_emerge/EbuildMetadataPhase.py +++ b/pym/_emerge/EbuildMetadataPhase.py @@ -1,4 +1,4 @@ -# Copyright 1999-2009 Gentoo Foundation +# Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from _emerge.SubProcess import SubProcess @@ -83,7 +83,7 @@ class EbuildMetadataPhase(SubProcess): fd_pipes[self._metadata_fd] = slave_fd self._raw_metadata = [] - files.ebuild = os.fdopen(master_fd, 'rb') + files.ebuild = os.fdopen(master_fd, 'rb', 0) self._reg_id = self.scheduler.register(files.ebuild.fileno(), self._registered_events, self._output_handler) self._registered = True diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py index d2f226cd0..6fc7489aa 100644 --- a/pym/portage/package/ebuild/doebuild.py +++ b/pym/portage/package/ebuild/doebuild.py @@ -587,7 +587,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, mypids = _spawn_phase(mydo, mysettings, returnpid=True, fd_pipes=fd_pipes) os.close(pw) # belongs exclusively to the child process now - f = os.fdopen(pr, 'rb') + f = os.fdopen(pr, 'rb', 0) for k, v in zip(auxdbkeys, (_unicode_decode(line).rstrip('\n') for line in f)): dbkey[k] = v diff --git a/pym/portage/tests/lazyimport/test_lazy_import_portage_baseline.py b/pym/portage/tests/lazyimport/test_lazy_import_portage_baseline.py index 14ed3a1f8..7c3b2f99a 100644 --- a/pym/portage/tests/lazyimport/test_lazy_import_portage_baseline.py +++ b/pym/portage/tests/lazyimport/test_lazy_import_portage_baseline.py @@ -1,4 +1,4 @@ -# Copyright 2010 Gentoo Foundation +# Copyright 2010-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import re @@ -53,7 +53,7 @@ sys.stdout.write(" ".join(k for k in sys.modules scheduler = PollScheduler().sched_iface master_fd, slave_fd = os.pipe() - master_file = os.fdopen(master_fd, 'rb') + master_file = os.fdopen(master_fd, 'rb', 0) slave_file = os.fdopen(slave_fd, 'wb') producer = SpawnProcess( args=self._baseline_import_cmd, diff --git a/pym/portage/tests/process/test_poll.py b/pym/portage/tests/process/test_poll.py index 9df2e88ae..ee6ee0c3f 100644 --- a/pym/portage/tests/process/test_poll.py +++ b/pym/portage/tests/process/test_poll.py @@ -1,4 +1,4 @@ -# Copyright 1998-2010 Gentoo Foundation +# Copyright 1998-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from portage import os @@ -20,7 +20,7 @@ class PipeReaderTestCase(TestCase): scheduler = PollScheduler().sched_iface master_fd, slave_fd = os.pipe() - master_file = os.fdopen(master_fd, 'rb') + master_file = os.fdopen(master_fd, 'rb', 0) slave_file = os.fdopen(slave_fd, 'wb') producer = SpawnProcess( args=["bash", "-c", "echo -n '%s'" % test_string], -- cgit v1.2.3-65-gdbad