[pypy-commit] pypy stdlib-2.7.8: (alex, dreid): fixed a bug in the utf7 decoder where unconsumed characters would still be returned

alex_gaynor noreply at buildbot.pypy.org
Thu Aug 28 01:18:41 CEST 2014


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: stdlib-2.7.8
Changeset: r73106:4f71852efa78
Date: 2014-08-27 16:18 -0700
http://bitbucket.org/pypy/pypy/changeset/4f71852efa78/

Log:	(alex, dreid): fixed a bug in the utf7 decoder where unconsumed
	characters would still be returned

diff --git a/rpython/rlib/runicode.py b/rpython/rlib/runicode.py
--- a/rpython/rlib/runicode.py
+++ b/rpython/rlib/runicode.py
@@ -906,7 +906,7 @@
     elif inShift:
         pos = shiftOutStartPos # back off output
 
-    return result.build(), pos
+    return result.build()[:pos], pos
 
 def unicode_encode_utf_7(s, size, errors, errorhandler=None):
     if size == 0:
diff --git a/rpython/rlib/test/test_runicode.py b/rpython/rlib/test/test_runicode.py
--- a/rpython/rlib/test/test_runicode.py
+++ b/rpython/rlib/test/test_runicode.py
@@ -231,6 +231,8 @@
         assert decode(s, 4, None) == (u'a+-', 4)
         assert decode(s, 5, None) == (u'a+-b', 5)
 
+        assert decode((27 * u"\u3042" + "\n").encode('utf7')[:28], 28, None) == (u'', 0)
+
     def test_utf7_surrogates(self):
         encode = self.getencoder('utf-7')
         u = u'\U000abcde'


More information about the pypy-commit mailing list