[pypy-commit] pypy py3k: kill, kill :-). We no longer need to check whether we are passing a subclass of unicode which defines __unicode__ when we pass an encoding paramter. As a bonus, test_unicodeobject.test_str_subclass now passes
antocuni
noreply at buildbot.pypy.org
Fri Mar 16 15:48:35 CET 2012
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r53722:b3a294a30297
Date: 2012-03-16 14:13 +0100
http://bitbucket.org/pypy/pypy/changeset/b3a294a30297/
Log: kill, kill :-). We no longer need to check whether we are passing a
subclass of unicode which defines __unicode__ when we pass an
encoding paramter. As a bonus, test_unicodeobject.test_str_subclass
now passes
diff --git a/pypy/objspace/std/unicodetype.py b/pypy/objspace/std/unicodetype.py
--- a/pypy/objspace/std/unicodetype.py
+++ b/pypy/objspace/std/unicodetype.py
@@ -304,23 +304,13 @@
w_obj = w_object
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.isinstance_w(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'))
- w_value = w_obj
+ if encoding is None and errors is None:
+ w_value = unicode_from_object(space, w_obj)
else:
- if encoding is None and errors is None:
- w_value = unicode_from_object(space, w_obj)
- else:
- w_value = unicode_from_encoded_object(space, w_obj,
- encoding, errors)
- if space.is_w(w_unicodetype, space.w_unicode):
- return w_value
+ w_value = unicode_from_encoded_object(space, w_obj,
+ encoding, errors)
+ if space.is_w(w_unicodetype, space.w_unicode):
+ return w_value
if space.config.objspace.std.withropeunicode:
assert isinstance(w_value, W_RopeUnicodeObject)
More information about the pypy-commit
mailing list