[issue11262] re.sub replaces only first 32 matches with re.U flag

Eugene Morozov report at bugs.python.org
Sun Feb 20 23:28:14 CET 2011


New submission from Eugene Morozov <eugene.morozov at gmail.com>:

There's a peculiar and difficult to find bug in the re.sub method. Try following example:
>>> text = 'X'*4096
>>> nt = re.sub(u"XX", u".", text, re.U)
>>> nt
u'............XXXXXXXXXXXXXXXXXXX' (only 32 dots, the rest of the string is not changed).

If I first compile regexp, and then perform compiled_regexp.sub, everything seems to work correctly.

----------
components: Regular Expressions
messages: 128923
nosy: Eugene.Morozov
priority: normal
severity: normal
status: open
title: re.sub replaces only first 32 matches with re.U flag
type: security
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11262>
_______________________________________


More information about the Python-bugs-list mailing list