[Patches] [ python-Patches-680863 ] replace() method in unicode objects
SourceForge.net
noreply@sourceforge.net
Mon, 10 Feb 2003 12:20:45 -0800
Patches item #680863, was opened at 2003-02-05 08:15
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=680863&group_id=5470
Category: Core (C code)
Group: Python 2.2.x
Status: Open
Resolution: None
Priority: 5
Submitted By: Fredrik Juhlin (faeltir)
Assigned to: Nobody/Anonymous (nobody)
Summary: replace() method in unicode objects
Initial Comment:
Hi,
I found that unlike the string object, the replace()
method in the unicode object doesn't throw an exception
when you supply an empty pattern string. Instead it
slaps on the replace string a few times at the end.
I'm supplying a patch to make the unicode object behave
like the string object.
I realize that in 2.3, doing replace() with an empty
pattern string will work differently so maybe you don't
consider throwing an exception the Right Way(TM), but
I'm presenting it to you in case you (like me) thinks
it's just better if unicode and string objects behave
in the same way while not changing the way that string
objects currently work in 2.2.
Best regards,
Fredrik Juhlin
----------------------------------------------------------------------
>Comment By: Neal Norwitz (nnorwitz)
Date: 2003-02-10 15:20
Message:
Logged In: YES
user_id=33168
The change for 2.3 was on purpose. See
Objects/stringobject.c 2.184 which fixed SF bug 595350.
Hmmm, unicode doesn't even do it right in 2.2.2+
>>> u"x".replace("", "a")
u'xaa'
Not sure what to do to fix for 2.2.3. :-(
----------------------------------------------------------------------
Comment By: Just van Rossum (jvr)
Date: 2003-02-10 14:36
Message:
Logged In: YES
user_id=92689
What I'm not sure of is whether the fact that this:
"x".replace("", "a")
raises an exception in 2.2 and "works" in 2.3 is intentional. It returns this in 2.3: 'axa'.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=680863&group_id=5470