[pypy-svn] r71050 - in pypy/trunk/pypy/module/_codecs: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Feb 2 10:57:41 CET 2010


Author: cfbolz
Date: Tue Feb  2 10:57:40 2010
New Revision: 71050

Modified:
   pypy/trunk/pypy/module/_codecs/interp_codecs.py
   pypy/trunk/pypy/module/_codecs/test/test_codecs.py
Log:
fix the case where the string is empty :-(


Modified: pypy/trunk/pypy/module/_codecs/interp_codecs.py
==============================================================================
--- pypy/trunk/pypy/module/_codecs/interp_codecs.py	(original)
+++ pypy/trunk/pypy/module/_codecs/interp_codecs.py	Tue Feb  2 10:57:40 2010
@@ -318,12 +318,12 @@
 
 def charmap_decode(space, s, errors="strict", w_mapping=None):
     size = len(s)
-##    /* Default to Latin-1 */
+    # Default to Latin-1
     if space.is_true(space.is_(w_mapping, space.w_None)):
         return latin_1_decode(space, s, errors, space.w_False)
 
     if (size == 0):
-        return space.wrap(u'')
+        return space.newtuple([space.wrap(u''), space.wrap(0)])
     
     # fast path for all the stuff in the encodings module
     if space.is_true(space.isinstance(w_mapping, space.w_tuple)):

Modified: pypy/trunk/pypy/module/_codecs/test/test_codecs.py
==============================================================================
--- pypy/trunk/pypy/module/_codecs/test/test_codecs.py	(original)
+++ pypy/trunk/pypy/module/_codecs/test/test_codecs.py	Tue Feb  2 10:57:40 2010
@@ -118,6 +118,7 @@
 
     def test_charmap_decode(self):
         from _codecs import charmap_decode
+        assert charmap_decode('', 'strict', 'blablabla') == ('', 0)
         assert charmap_decode('xxx') == ('xxx', 3)
         assert charmap_decode('xxx', 'strict', {ord('x'): u'XX'}) == ('XXXXXX', 3)
         map = tuple([unichr(i) for i in range(256)])



More information about the Pypy-commit mailing list