[New-bugs-announce] [issue34851] re.error - for the search function in the re module
Bnaya
report at bugs.python.org
Sun Sep 30 04:37:44 EDT 2018
New submission from Bnaya <bnaya.honig at gmail.com>:
I was writing the following:
re.search('([+-*])', "54 * 83")
And I got the following runtime error:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Users\bnaya\AppData\Local\Programs\Python\Python37-32\lib\re.py", line 183, in search
return _compile(pattern, flags).search(string)
File "C:\Users\bnaya\AppData\Local\Programs\Python\Python37-32\lib\re.py", line 286, in _compile
p = sre_compile.compile(pattern, flags)
File "C:\Users\bnaya\AppData\Local\Programs\Python\Python37-32\lib\sre_compile.py", line 764, in compile
p = sre_parse.parse(p, flags)
File "C:\Users\bnaya\AppData\Local\Programs\Python\Python37-32\lib\sre_parse.py", line 930, in parse
p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
File "C:\Users\bnaya\AppData\Local\Programs\Python\Python37-32\lib\sre_parse.py", line 426, in _parse_sub
not nested and not items))
File "C:\Users\bnaya\AppData\Local\Programs\Python\Python37-32\lib\sre_parse.py", line 816, in _parse
p = _parse_sub(source, state, sub_verbose, nested + 1)
File "C:\Users\bnaya\AppData\Local\Programs\Python\Python37-32\lib\sre_parse.py", line 426, in _parse_sub
not nested and not items))
File "C:\Users\bnaya\AppData\Local\Programs\Python\Python37-32\lib\sre_parse.py", line 580, in _parse
raise source.error(msg, len(this) + 1 + len(that))
re.error: bad character range +-* at position 2
Note that for different operators order, such as:
re.search('([+*-])', "54 * 83")
or
re.search('([*+-])', "54 * 83")
the function worked just fine.
----------
components: Regular Expressions
messages: 326716
nosy: Bnaya, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: re.error - for the search function in the re module
type: crash
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34851>
_______________________________________
More information about the New-bugs-announce
mailing list