[pypy-svn] r58660 - in pypy/branch/2.5-merge/pypy/module/_codecs: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Mon Oct 6 16:28:16 CEST 2008


Author: cfbolz
Date: Mon Oct  6 16:28:16 2008
New Revision: 58660

Modified:
   pypy/branch/2.5-merge/pypy/module/_codecs/app_codecs.py
   pypy/branch/2.5-merge/pypy/module/_codecs/test/test_codecs.py
Log:
(xoraxax, cfbolz, arigo around) bugs in codecs, found by some CPython tests: The
second element of the returned tuple (the consumed length) is the length of the
_input_ string, not the output string. Design seems a bit strange. No clue how
it is for encoders.


Modified: pypy/branch/2.5-merge/pypy/module/_codecs/app_codecs.py
==============================================================================
--- pypy/branch/2.5-merge/pypy/module/_codecs/app_codecs.py	(original)
+++ pypy/branch/2.5-merge/pypy/module/_codecs/app_codecs.py	Mon Oct  6 16:28:16 2008
@@ -66,14 +66,14 @@
     """
     res = PyUnicode_DecodeRawUnicodeEscape(data, len(data), errors)
     res = u''.join(res)
-    return res, len(res)
+    return res, len(data)
 
 def utf_7_decode( data, errors='strict'):
     """None
     """
     res = PyUnicode_DecodeUTF7(data, len(data), errors)
     res = u''.join(res)
-    return res, len(res)
+    return res, len(data)
 
 def unicode_escape_encode( obj, errors='strict'):
     """None
@@ -87,7 +87,7 @@
     """
     res = PyUnicode_DecodeUnicodeEscape(data, len(data), errors)
     res = u''.join(res)
-    return res, len(res)
+    return res, len(data)
 
 
 def charmap_encode(obj, errors='strict', mapping='latin-1'):
@@ -147,7 +147,7 @@
             i += unicode_bytes
             p += unichr(t)
         res = u''.join(p)
-        return res, len(res)
+        return res, len(unistr)
 
 # XXX needs error messages when the input is invalid
 def escape_decode(data, errors='strict'):
@@ -197,7 +197,7 @@
             res += data[i]
         i += 1
     res = ''.join(res)    
-    return res, len(res)
+    return res, len(data)
 
 def charbuffer_encode( obj, errors='strict'):
     """None
@@ -211,7 +211,7 @@
     """
     res = PyUnicode_DecodeCharmap(data, len(data), mapping, errors)
     res = ''.join(res)
-    return res, len(res)
+    return res, len(data)
 
 
 def utf_7_encode( obj, errors='strict'):

Modified: pypy/branch/2.5-merge/pypy/module/_codecs/test/test_codecs.py
==============================================================================
--- pypy/branch/2.5-merge/pypy/module/_codecs/test/test_codecs.py	(original)
+++ pypy/branch/2.5-merge/pypy/module/_codecs/test/test_codecs.py	Mon Oct  6 16:28:16 2008
@@ -299,7 +299,6 @@
         raises(TypeError, "\\uyyyy".decode, "raw-unicode-escape", "test.baddecodereturn1")
 
     def test_cpy_bug1175396(self):
-        skip('utf-7 decoder bug')
         import codecs, StringIO
         s = [
             '<%!--===================================================\r\n',



More information about the Pypy-commit mailing list