Fix PipeReader and PipeReaderTestCase to work with binary strings in py3k.
authorZac Medico <zmedico@gentoo.org>
Wed, 11 Mar 2009 06:23:46 +0000 (06:23 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 11 Mar 2009 06:23:46 +0000 (06:23 -0000)
(trunk r12720)

svn path=/main/branches/2.1.6/; revision=12975

pym/_emerge/__init__.py
pym/portage/tests/process/test_poll.py

index a6332b4f602901d886c7ca8a0c7835b537a07a76..43ed4196d9924c1087654e0b43e36f9dc59ac6e1 100644 (file)
@@ -1960,6 +1960,8 @@ class PipeReader(AbstractPollTask):
 
        def getvalue(self):
                """Retrieve the entire contents"""
+               if sys.hexversion >= 0x3000000:
+                       return bytes().join(self._read_data)
                return "".join(self._read_data)
 
        def close(self):
index 9049304104ea061f40012009fabcf30888f5739a..e399c479dbe52529b85966287179783e059034a3 100644 (file)
@@ -28,7 +28,7 @@ class PipeReaderTestCase(TestCase):
                test_string = 2 * "blah blah blah\n"
 
                master_fd, slave_fd = self._create_pipe()
-               master_file = os.fdopen(master_fd, 'r')
+               master_file = os.fdopen(master_fd, 'rb')
 
                task_scheduler = TaskScheduler(max_jobs=2)
                scheduler = task_scheduler.sched_iface
@@ -52,4 +52,7 @@ class PipeReaderTestCase(TestCase):
 
                task_scheduler.run()
 
+               if sys.hexversion >= 0x3000000:
+                       test_string = test_string.encode()
+
                self._assertEqual(test_string, consumer.getvalue())