[pypy-svn] r55939 - in pypy/dist/pypy/objspace/std: . test

fijal at codespeak.net fijal at codespeak.net
Wed Jun 18 02:11:28 CEST 2008


Author: fijal
Date: Wed Jun 18 02:11:25 2008
New Revision: 55939

Modified:
   pypy/dist/pypy/objspace/std/test/test_stringobject.py
   pypy/dist/pypy/objspace/std/unicodeobject.py
   pypy/dist/pypy/objspace/std/unicodetype.py
Log:
unicode.decode method


Modified: pypy/dist/pypy/objspace/std/test/test_stringobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_stringobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_stringobject.py	Wed Jun 18 02:11:25 2008
@@ -645,6 +645,7 @@
     def test_decode(self):
         assert 'hello'.decode('rot-13') == 'uryyb'
         assert 'hello'.decode('string-escape') == 'hello'
+        assert u'hello'.decode('rot-13') == 'uryyb'
 
     def test_encode(self):
         assert 'hello'.encode() == 'hello'

Modified: pypy/dist/pypy/objspace/std/unicodeobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/unicodeobject.py	(original)
+++ pypy/dist/pypy/objspace/std/unicodeobject.py	Wed Jun 18 02:11:25 2008
@@ -773,6 +773,14 @@
     w_retval = encode_object(space, w_unistr, encoding, errors)
     return w_retval
 
+def unicode_decode__Unicode_ANY_ANY(space, w_unicode, w_encoding=None, w_errors=None):
+    from pypy.objspace.std.unicodetype import _get_encoding_and_errors,\
+         decode_object
+    encoding, errors = _get_encoding_and_errors(space, w_encoding, w_errors)
+    if encoding is None and errors is None:
+        return unicode_from_string(space, w_string)
+    return decode_object(space, w_unicode, encoding, errors)
+
 def unicode_partition__Unicode_Unicode(space, w_unistr, w_unisub):
     unistr = w_unistr._value
     unisub = w_unisub._value

Modified: pypy/dist/pypy/objspace/std/unicodetype.py
==============================================================================
--- pypy/dist/pypy/objspace/std/unicodetype.py	(original)
+++ pypy/dist/pypy/objspace/std/unicodetype.py	Wed Jun 18 02:11:25 2008
@@ -147,6 +147,7 @@
 from pypy.objspace.std.stringtype import str_strip as unicode_strip
 from pypy.objspace.std.stringtype import str_rstrip as unicode_rstrip
 from pypy.objspace.std.stringtype import str_lstrip as unicode_lstrip
+from pypy.objspace.std.stringtype import str_decode as unicode_decode
 
 # ____________________________________________________________
 



More information about the Pypy-commit mailing list