GitLab will be upgraded on June 2nd 2020 at 2.00 pm (AEDT) to 3.00 pm (AEDT) due to Critical Security Patch Availability. During the update, GitLab and Mattermost services will not be available. If you have any concerns with this, please talk to local Gitlab admin team.

Commit 78fb34b0 authored by Armin Rigo's avatar Armin Rigo


parent 4cd5cdbc
......@@ -707,19 +707,7 @@ class W_BytesObject(W_AbstractBytesObject):
new_is_unicode = space.isinstance_w(w_new, space.w_unicode)
if old_is_unicode or new_is_unicode:
self_as_uni = unicode_from_encoded_object(space, self, None, None)
if not old_is_unicode:
w_old = unicode_from_encoded_object(space, w_old, None, None)
if not new_is_unicode:
w_new = unicode_from_encoded_object(space, w_new, None, None)
input = self_as_uni._val(space)
sub = self_as_uni._op_val(space, w_old)
by = self_as_uni._op_val(space, w_new)
res = replace(input, sub, by, count)
except OverflowError:
raise oefmt(space.w_OverflowError,
"replace string is too long")
return self_as_uni._new(res)
return self_as_uni.descr_replace(space, w_old, w_new, count)
return self._StringMethods_descr_replace(space, w_old, w_new, count)
_StringMethods_descr_join = descr_join
......@@ -956,10 +956,12 @@ class AppTestUnicodeString:
assert not u'a'.isnumeric()
assert u'\u2460'.isnumeric() # CIRCLED DIGIT ONE
def test_replace_autoconvert(self):
def test_replace_str_unicode(self):
res = 'one!two!three!'.replace(u'!', u'@', 1)
assert res == u'one@two!three!'
assert type(res) == unicode
raises(UnicodeDecodeError, '\x80'.replace, 'a', u'b')
raises(UnicodeDecodeError, '\x80'.replace, u'a', 'b')
def test_join_subclass(self):
class UnicodeSubclass(unicode):
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment