[Python-bugs-list] [ python-Bugs-635398 ] re.sub() coerces u'' to ''
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 08 Nov 2002 01:32:14 -0800
Bugs item #635398, was opened at 2002-11-08 02: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().
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=635398&group_id=5470