Avoid using the wrapped os.read(), in order to avoid differing behavior
authorZac Medico <zmedico@gentoo.org>
Tue, 11 Aug 2009 07:03:04 +0000 (07:03 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 11 Aug 2009 07:03:04 +0000 (07:03 -0000)
between python-2.x (with wrapper) and py3k (without wrapper). This sort
of mismatch only applies to os functions that return raw bytes under py3k,
rather than unicode.

svn path=/main/trunk/; revision=13992

pym/portage/__init__.py

index cb6958e95f6136a7be642a844fd037ab2e29750f..7c829e96c63b09afa7ae3a3743e52e60e01be7ec 100644 (file)
@@ -6168,16 +6168,11 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
                                        mysettings,
                                        fd_pipes=fd_pipes, returnpid=True, droppriv=droppriv)
                                os.close(pw) # belongs exclusively to the child process now
-                               maxbytes = 1024
-                               mybytes = []
-                               while True:
-                                       mybytes.append(os.read(pr, maxbytes))
-                                       if not mybytes[-1]:
-                                               break
-                               os.close(pr)
-                               global auxdbkeys
-                               for k, v in izip(auxdbkeys, ''.join(mybytes).splitlines()):
+                               f = os.fdopen(pr, 'rb')
+                               for k, v in izip(auxdbkeys,
+                                       (_unicode_decode(line).rstrip('\n') for line in f)):
                                        dbkey[k] = v
+                               f.close()
                                retval = os.waitpid(mypids[0], 0)[1]
                                portage.process.spawned_pids.remove(mypids[0])
                                # If it got a signal, return the signal that was sent, but