From b791c4d5b78df5a8e514f5e17ea8f5faca00350c Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 25 Sep 2009 06:01:56 +0000 Subject: [PATCH] Fix length calculation so it doesn't assume the length of the encoded string is the same as the unicode string. svn path=/main/trunk/; revision=14424 --- pym/portage/tests/ebuild/test_array_fromfile_eof.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pym/portage/tests/ebuild/test_array_fromfile_eof.py b/pym/portage/tests/ebuild/test_array_fromfile_eof.py index 8eacb406b..eebf0234c 100644 --- a/pym/portage/tests/ebuild/test_array_fromfile_eof.py +++ b/pym/portage/tests/ebuild/test_array_fromfile_eof.py @@ -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 -- 2.26.2