diff options
-rw-r--r-- | pym/_emerge/PipeReader.py | 6 | ||||
-rw-r--r-- | pym/_emerge/SpawnProcess.py | 6 | ||||
-rw-r--r-- | pym/portage/tests/ebuild/test_array_fromfile_eof.py | 11 | ||||
-rw-r--r-- | pym/portage/util/_pty.py | 8 | ||||
-rw-r--r-- | pym/portage/xpak.py | 7 |
5 files changed, 27 insertions, 11 deletions
diff --git a/pym/_emerge/PipeReader.py b/pym/_emerge/PipeReader.py index 375c98f6a..02e550dce 100644 --- a/pym/_emerge/PipeReader.py +++ b/pym/_emerge/PipeReader.py @@ -70,7 +70,11 @@ class PipeReader(AbstractPollTask): pass if buf: - self._read_data.append(buf.tostring()) + try: + data = buf.tobytes() + except AttributeError: + data = buf.tostring() + self._read_data.append(data) else: self._unregister() self.wait() diff --git a/pym/_emerge/SpawnProcess.py b/pym/_emerge/SpawnProcess.py index b72971c87..aa4160572 100644 --- a/pym/_emerge/SpawnProcess.py +++ b/pym/_emerge/SpawnProcess.py @@ -206,7 +206,11 @@ class SpawnProcess(SubProcess): buf.tofile(files.log) except TypeError: # array.tofile() doesn't work with GzipFile - files.log.write(buf.tostring()) + try: + data = buf.tobytes() + except AttributeError: + data = buf.tostring() + files.log.write(data) files.log.flush() else: self._unregister() diff --git a/pym/portage/tests/ebuild/test_array_fromfile_eof.py b/pym/portage/tests/ebuild/test_array_fromfile_eof.py index d8277f275..f965b8384 100644 --- a/pym/portage/tests/ebuild/test_array_fromfile_eof.py +++ b/pym/portage/tests/ebuild/test_array_fromfile_eof.py @@ -1,4 +1,4 @@ -# Copyright 2009 Gentoo Foundation +# Copyright 2009-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import array @@ -35,9 +35,12 @@ class ArrayFromfileEofTestCase(TestCase): if not a: eof = True else: - data.append(_unicode_decode(a.tostring(), - encoding='utf_8', errors='strict')) + try: + data.append(a.tobytes()) + except AttributeError: + data.append(a.tostring()) f.close() - self.assertEqual(input_data, ''.join(data)) + self.assertEqual(input_data, _unicode_decode(b''.join(data), + encoding='utf_8', errors='strict')) diff --git a/pym/portage/util/_pty.py b/pym/portage/util/_pty.py index f45ff0aa1..f308ccbce 100644 --- a/pym/portage/util/_pty.py +++ b/pym/portage/util/_pty.py @@ -112,12 +112,14 @@ def _test_pty_eof(fdopen_buffered=False): if not buf: eof = True else: - data.append(_unicode_decode(buf.tostring(), - encoding='utf_8', errors='strict')) + try: + data.append(buf.tobytes()) + except AttributeError: + data.append(buf.tostring()) master_file.close() - return test_string == ''.join(data) + return test_string == _unicode_decode(b''.join(data), encoding='utf_8', errors='strict') # If _test_pty_eof() can't be used for runtime detection of # http://bugs.python.org/issue5380, openpty can't safely be used diff --git a/pym/portage/xpak.py b/pym/portage/xpak.py index 7487d6728..b13e257dc 100644 --- a/pym/portage/xpak.py +++ b/pym/portage/xpak.py @@ -1,4 +1,4 @@ -# Copyright 2001-2010 Gentoo Foundation +# Copyright 2001-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 @@ -66,7 +66,10 @@ def encodeint(myint): a.append((myint >> 16 ) & 0xff) a.append((myint >> 8 ) & 0xff) a.append(myint & 0xff) - return a.tostring() + try: + return a.tobytes() + except AttributeError: + return a.tostring() def decodeint(mystring): """Takes a 4 byte string and converts it into a 4 byte integer. |