Author: Philip Jenvey <pjen...@underboss.org> Branch: stdlib-3.2.5 Changeset: r70427:bb6d5f9788c9 Date: 2014-04-03 15:04 -0700 http://bitbucket.org/pypy/pypy/changeset/bb6d5f9788c9/
Log: fix str() w/ out an object specified & kw only args diff --git a/pypy/objspace/std/test/test_unicodeobject.py b/pypy/objspace/std/test/test_unicodeobject.py --- a/pypy/objspace/std/test/test_unicodeobject.py +++ b/pypy/objspace/std/test/test_unicodeobject.py @@ -341,12 +341,14 @@ assert str(123) == '123' assert str(object=123) == '123' assert str([2, 3]) == '[2, 3]' + assert str(errors='strict') == '' class U(str): pass assert str(U()).__class__ is str assert U().__str__().__class__ is str assert U('test') == 'test' assert U('test').__class__ is U + assert U(errors='strict') == U('') def test_call_unicode_2(self): class X(object): diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py --- a/pypy/objspace/std/unicodeobject.py +++ b/pypy/objspace/std/unicodeobject.py @@ -157,20 +157,18 @@ return space.newlist_unicode(lst) @staticmethod - @unwrap_spec(w_object=WrappedDefault(u'')) def descr_new(space, w_unicodetype, w_object=None, w_encoding=None, w_errors=None): - # NB. the default value of w_obj is really a *wrapped* empty string: - # there is gateway magic at work - w_obj = w_object - - encoding, errors = _get_encoding_and_errors(space, w_encoding, - w_errors) - if encoding is None and errors is None: - w_value = unicode_from_object(space, w_obj) + if w_object is None: + w_value = W_UnicodeObject.EMPTY else: - w_value = unicode_from_encoded_object(space, w_obj, encoding, - errors) + encoding, errors = _get_encoding_and_errors(space, w_encoding, + w_errors) + if encoding is None and errors is None: + w_value = unicode_from_object(space, w_object) + else: + w_value = unicode_from_encoded_object(space, w_object, + encoding, errors) if space.is_w(w_unicodetype, space.w_unicode): return w_value _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit