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()
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()
-# Copyright 2009 Gentoo Foundation
+# Copyright 2009-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
import array
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'))
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
-# Copyright 2001-2010 Gentoo Foundation
+# Copyright 2001-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
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.