[pypy-svn] pypy default: Test and fix in unicode_encode_utf_7
amauryfa
commits-noreply at bitbucket.org
Thu Feb 10 14:43:19 CET 2011
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch:
Changeset: r41775:8b5da4af26cf
Date: 2011-02-10 13:57 +0100
http://bitbucket.org/pypy/pypy/changeset/8b5da4af26cf/
Log: Test and fix in unicode_encode_utf_7
diff --git a/pypy/rlib/test/test_runicode.py b/pypy/rlib/test/test_runicode.py
--- a/pypy/rlib/test/test_runicode.py
+++ b/pypy/rlib/test/test_runicode.py
@@ -280,6 +280,10 @@
py.test.raises(UnicodeDecodeError, runicode.str_decode_utf_16_le,
s, len(s), True)
+ def test_utf7_bugs(self):
+ u = u'A\u2262\u0391.'
+ assert runicode.unicode_encode_utf_7(u, len(u), None) == 'A+ImIDkQ.'
+
def test_utf7_partial(self):
s = u"a+-b".encode('utf-7')
assert s == "a+--b"
diff --git a/pypy/rlib/runicode.py b/pypy/rlib/runicode.py
--- a/pypy/rlib/runicode.py
+++ b/pypy/rlib/runicode.py
@@ -829,7 +829,7 @@
if _utf7_ENCODE_DIRECT(oc, not encodeSetO, not encodeWhiteSpace):
# shifting out
if base64bits: # output remaining bits
- result.append(_utf7_TO_BASE64(base64buffer >> (base64bits-6)))
+ result.append(_utf7_TO_BASE64(base64buffer << (6-base64bits)))
base64buffer = 0
base64bits = 0
More information about the Pypy-commit
mailing list