[pypy-svn] pypy fast-forward: Allow unterminated utf7 sequences when final=False
amauryfa
commits-noreply at bitbucket.org
Sun Jan 16 19:38:30 CET 2011
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: fast-forward
Changeset: r40736:76915c45fdd6
Date: 2011-01-16 19:13 +0100
http://bitbucket.org/pypy/pypy/changeset/76915c45fdd6/
Log: Allow unterminated utf7 sequences when final=False
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
@@ -174,6 +174,16 @@
py.test.raises(UnicodeDecodeError, runicode.str_decode_utf_16_le,
s, len(s), True)
+ def test_utf7_partial(self):
+ s = u"a+-b".encode('utf-7')
+ assert s == "a+--b"
+ decode = self.getdecoder('utf-7')
+ assert decode(s, 1, None)[0] == u'a'
+ assert decode(s, 2, None)[0] == u'a'
+ assert decode(s, 3, None)[0] == u'a+'
+ assert decode(s, 4, None)[0] == u'a+-'
+ assert decode(s, 5, None)[0] == u'a+-b'
+
class TestEncoding(UnicodeTests):
def test_all_ascii(self):
diff --git a/pypy/rlib/runicode.py b/pypy/rlib/runicode.py
--- a/pypy/rlib/runicode.py
+++ b/pypy/rlib/runicode.py
@@ -733,7 +733,7 @@
result.append(unichr(oc))
pos += 1
- if inShift:
+ if inShift and final:
endinpos = size
msg = "unterminated shift sequence"
res, pos = errorhandler(errors, 'utf-7', msg, s, startinpos, pos)
More information about the Pypy-commit
mailing list