Fix length calculation so it doesn't assume the length of the encoded
authorZac Medico <zmedico@gentoo.org>
Fri, 25 Sep 2009 06:01:56 +0000 (06:01 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 25 Sep 2009 06:01:56 +0000 (06:01 -0000)
string is the same as the unicode string.

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

pym/portage/tests/ebuild/test_array_fromfile_eof.py

index 8eacb406bd7df2e2c169eb4f1f830bb646ab83c8..eebf0234c36fe350088a1b5887b144d6a95ca607 100644 (file)
@@ -18,9 +18,10 @@ class ArrayFromfileEofTestCase(TestCase):
                #   http://bugs.python.org/issue5334
 
                input_data = "an arbitrary string"
+               input_bytes = _unicode_encode(input_data,
+                       encoding='utf_8', errors='strict')
                f = tempfile.TemporaryFile()
-               f.write(_unicode_encode(input_data,
-                       encoding='utf_8', errors='strict'))
+               f.write(input_bytes)
 
                f.seek(0)
                data = []
@@ -28,7 +29,7 @@ class ArrayFromfileEofTestCase(TestCase):
                while not eof:
                        a = array.array('B')
                        try:
-                               a.fromfile(f, len(input_data) + 1)
+                               a.fromfile(f, len(input_bytes) + 1)
                        except EOFError:
                                # python-3.0 lost data here
                                eof = True