summaryrefslogtreecommitdiffstats
path: root/pym/portage
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-08-24 19:48:17 -0700
committerZac Medico <zmedico@gentoo.org>2011-08-24 19:48:17 -0700
commit148fc6a73f3fa3b53039ee3292e222015e96bc79 (patch)
tree53086f32b3be1359d77d90e1e094fdcb75d0a5d9 /pym/portage
parenta12c63842b28e29f3bc6718e6d940d5b697f010f (diff)
downloadportage-148fc6a73f3fa3b53039ee3292e222015e96bc79.tar.gz
portage-148fc6a73f3fa3b53039ee3292e222015e96bc79.tar.bz2
portage-148fc6a73f3fa3b53039ee3292e222015e96bc79.zip
python3.2 fixes: use array.tobytes()
Diffstat (limited to 'pym/portage')
-rw-r--r--pym/portage/tests/ebuild/test_array_fromfile_eof.py11
-rw-r--r--pym/portage/util/_pty.py8
-rw-r--r--pym/portage/xpak.py7
3 files changed, 17 insertions, 9 deletions
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.