[pypy-svn] pypy default: utf-7: in incremental decoder, don't eat the unterminated shift sequence

amauryfa commits-noreply at bitbucket.org
Mon Jan 17 23:42:55 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: 
Changeset: r40821:4abacff393df
Date: 2011-01-17 23:11 +0100
http://bitbucket.org/pypy/pypy/changeset/4abacff393df/

Log:	utf-7: in incremental decoder, don't eat the unterminated shift
	sequence

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
@@ -178,11 +178,11 @@
         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'
+        assert decode(s, 1, None) == (u'a', 1)
+        assert decode(s, 2, None) == (u'a', 1)
+        assert decode(s, 3, None) == (u'a+', 3)
+        assert decode(s, 4, None) == (u'a+-', 4)
+        assert decode(s, 5, None) == (u'a+-b', 5)
 
 
 class TestEncoding(UnicodeTests):

diff --git a/pypy/rlib/runicode.py b/pypy/rlib/runicode.py
--- a/pypy/rlib/runicode.py
+++ b/pypy/rlib/runicode.py
@@ -738,6 +738,8 @@
         msg = "unterminated shift sequence"
         res, pos = errorhandler(errors, 'utf-7', msg, s, startinpos, pos)
         result.append(res)
+    elif inShift:
+        pos = startinpos
 
     return result.build(), pos
 


More information about the Pypy-commit mailing list