[pypy-svn] r61409 - in pypy/trunk/pypy/objspace/std: . test

fijal at codespeak.net fijal at codespeak.net
Tue Jan 27 21:21:33 CET 2009


Author: fijal
Date: Tue Jan 27 21:21:29 2009
New Revision: 61409

Modified:
   pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py
   pypy/trunk/pypy/objspace/std/unicodetype.py
Log:
More convoluted logic :( This is kind of bug-to-bug compatibility


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	Tue Jan 27 21:21:29 2009
@@ -777,7 +777,6 @@
         assert u'abc'.replace(u'b', buffer('e')) == u'aec'
 
     def test_unicode_subclass(self):
-        skip("{fails}")
         class S(unicode):
             pass
 

Modified: pypy/trunk/pypy/objspace/std/unicodetype.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/unicodetype.py	(original)
+++ pypy/trunk/pypy/objspace/std/unicodetype.py	Tue Jan 27 21:21:29 2009
@@ -257,8 +257,12 @@
     from pypy.objspace.std.ropeunicodeobject import W_RopeUnicodeObject
     w_obj = w_string
 
-    encoding, errors = _get_encoding_and_errors(space, w_encoding, w_errors) 
-    if space.is_w(space.type(w_obj), space.w_unicode):
+    encoding, errors = _get_encoding_and_errors(space, w_encoding, w_errors)
+    # convoluted logic for the case when unicode subclass has a __unicode__
+    # method, we need to call this method
+    if (space.is_w(space.type(w_obj), space.w_unicode) or
+        (space.is_true(space.isinstance(w_obj, space.w_unicode)) and
+         space.findattr(w_obj, space.wrap('__unicode__')) is None)):
         if encoding is not None or errors is not None:
             raise OperationError(space.w_TypeError,
                                  space.wrap('decoding Unicode is not supported'))



More information about the Pypy-commit mailing list