[New-bugs-announce] [issue1140] re.sub returns str when processing empty unicode string

Beda Kosata report at bugs.python.org
Mon Sep 10 08:37:19 CEST 2007


New submission from Beda Kosata:

While re.sub normally returns unicode strings when processing unicode,
it returns a normal string when dealing with an empty unicode string.

Example:
>>> print type( re.sub( "XX", "", u""))
<type 'str'>
>>> print type( re.sub( "XX", "", u"A"))
<type 'unicode'>

This inconsistency could lead to annoying bugs (at least it did for me :)

----------
components: Regular Expressions
messages: 55775
nosy: beda
severity: minor
status: open
title: re.sub returns str when processing empty unicode string
type: behavior
versions: Python 2.4, Python 2.5

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1140>
__________________________________


More information about the New-bugs-announce mailing list