New submission from Dan Haffey:

Error reporting for recursive backreferences in regexes isn't consistent across 
both types of backref. Here's the exception for a recursive numeric backref:

>>> import re
>>> re.compile(r'(\1)')
Traceback (most recent call last):
    ...
sre_constants.error: cannot refer to an open group at position 1

Here's what I'm seeing on the 3.5 branch for a named backref:

>>> re.compile(r'(?P<spam>(?P=spam))')
Traceback (most recent call last):
    ...
RecursionError: maximum recursion depth exceeded

Which is an improvement over 3.4 and below, where compilation succeeds and 
appears to treat (?P=spam) as valid but unmatchable.

----------
components: Regular Expressions
messages: 246390
nosy: dhaffey, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: Wrong or missing exception when compiling regexes with recursive named 
backreferences
type: behavior

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24580>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to