[New-bugs-announce] [issue18190] RuntimeError raised with re.search + re.DOTALL on empty string

Harry Bock report at bugs.python.org
Tue Jun 11 16:40:35 CEST 2013


New submission from Harry Bock:

In Python 2.7.5, running re.search on regular expressions beginning with '.+' will raise RuntimeError if:
 * the string being matched is empty
 * the flags include re.DOTALL/re.S

>>> re.search(".+a", "", flags=re.S)
  File "C:\Python27\lib\site-packages\IPython\core\interactiveshell.py", line 2731, in run_code
    exec code_obj in self.user_global_ns, self.user_ns
  File "<ipython-input-16-fefa32a418ba>", line 1, in <module>
    myre.search("")
RuntimeError: internal error in regular expression engine

This does not occur if the input string is not empty, or if re.match is used instead of re.search, or if the re.S flag is omitted.

The bug does not occur on previous versions of Python 2.x, including 2.7.4.

----------
components: Regular Expressions
messages: 190966
nosy: ezio.melotti, hbock, mrabarnett
priority: normal
severity: normal
status: open
title: RuntimeError raised with re.search + re.DOTALL on empty string
type: behavior
versions: Python 2.7

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


More information about the New-bugs-announce mailing list