fdopen: read from processes in unbuffered mode v2.1.9.35
authorZac Medico <zmedico@gentoo.org>
Sat, 22 Jan 2011 00:50:59 +0000 (16:50 -0800)
committerZac Medico <zmedico@gentoo.org>
Sat, 22 Jan 2011 06:19:33 +0000 (22:19 -0800)
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
pym/portage/package/ebuild/doebuild.py
pym/portage/tests/lazyimport/test_lazy_import_portage_baseline.py
pym/portage/tests/process/test_poll.py

index eaa7f40b2d179ab5eb8aec3d3175a4bd80abf608..5925ec462a59b8a8122fb155658e4434ab8cc33c 100644 (file)
@@ -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
index d2f226cd0d22d4b84c43db73abe133593a3fadec..6fc7489aa7317a38de17091f976b1b8a3bc6a0a6 100644 (file)
@@ -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
index 14ed3a1f8c0b9cb22f7d6205e67982ba83274806..7c3b2f99a5c47fcd295d5d577f240879ed97d95f 100644 (file)
@@ -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,
index 9df2e88ae987023bdc793f39f8f6cab7523991bf..ee6ee0c3fb5a92f8fe68693fe5a96c1397077db6 100644 (file)
@@ -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],