Closed
Description
Bug report
Following regex causes re.compile()
to raise RuntimeError: invalid SRE code
:
re.compile(
r"(?P<h>^([01][0-9]|2[0-3]))"
r"((?P<m>([0-5][0-9]))?"
r"(?(5)(?P<s>([0-5][0-9]|60))?)"
r"(?(7)(\.(?P<ms>([0-9]{1,6})?))?))$"
)
Your environment
Python 3.11
- CPython versions tested on: 3.11
- Operating system and architecture: Linux (docker image as well as virtualenv)
I've checked and this hasn't been an issue in all previous Python interpreter versions, starting from 3.6 (the oldest I've checked).
What's more the regex is correctly recognized and does not cause any issues in other regexp implementations, e.g. the online tool https://regex101.com/
I've already asked about this on mailing list and confirmed that this is a bug.
@serhiy-storchaka has confirmed that the case for this bug has already been found.