[Python-bugs-list] [ python-Bugs-635398 ] re.sub() coerces u'' to ''

noreply@sourceforge.net noreply@sourceforge.net
Sat, 09 Nov 2002 10:05:35 -0800


Bugs item #635398, was opened at 2002-11-08 10:32
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=635398&group_id=5470

Category: Regular Expressions
Group: Python 2.2.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Mike Brown (mike_j_brown)
Assigned to: Fredrik Lundh (effbot)
Summary: re.sub() coerces u'' to ''

Initial Comment:
Using Python 2.2.1 on FreeBSD, these work as 
expected:

>>> re.sub(u'f', u'b', u'foo')  # keep string as Unicode
u'boo'
>>> re.sub(u'f', u'b', 'foo')   # coerce string to Unicode
u'boo'

But this doesn't work the way I think it should:

>>> re.sub(u'f', u'b', u'')     # coerce string to non-
Unicode?!
> ''

That is, an empty Unicode string does not survive as 
Unicode after going through re.sub().

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2002-11-09 19:05

Message:
Logged In: YES 
user_id=21627

Would you like to work on a patch for this bug?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=635398&group_id=5470