[pypy-svn] r59027 - in pypy/trunk/pypy: module/_codecs objspace/std/test

antocuni at codespeak.net antocuni at codespeak.net
Sun Oct 12 14:40:53 CEST 2008


Author: antocuni
Date: Sun Oct 12 14:40:52 2008
New Revision: 59027

Modified:
   pypy/trunk/pypy/module/_codecs/interp_codecs.py
   pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py
Log:
(antocuni, arigo, iko)
make unicode decoders accept also buffers as an argument



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	Sun Oct 12 14:40:52 2008
@@ -222,7 +222,7 @@
         result, consumed = func(string, len(string), errors,
                                 final, state.decode_error_handler)
         return space.newtuple([space.wrap(result), space.wrap(consumed)])
-    wrap_decoder.unwrap_spec = [ObjSpace, str, str, W_Root]
+    wrap_decoder.unwrap_spec = [ObjSpace, 'bufferstr', str, W_Root]
     globals()[name] = wrap_decoder
 
 for encoders in [

Modified: pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py	(original)
+++ pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py	Sun Oct 12 14:40:52 2008
@@ -663,3 +663,8 @@
     def test_encode_raw_unicode_escape(self):
         u = unicode('\\', 'raw_unicode_escape')
         assert u == u'\\'
+
+    def test_decode_from_buffer(self):
+        buf = buffer('character buffers are decoded to unicode')
+        u = unicode(buf, 'utf-8', 'strict')
+        assert u == u'character buffers are decoded to unicode'



More information about the Pypy-commit mailing list