Serhiy Storchaka added the comment:

The more I think about it, the more doubt. This patch added a behavior that is 
incompatible with the regex module. The regex module proceeds lookbehind 
assertions in the opposite direction, from right to left. This allows it to 
work with lookbehind assertions of non-fixed length. But the side effect is 
that in regex group reference in lookbehind assertion can refer only to a group 
defined right in the same lookbehind assertion (or defined left outside). In re 
now group reference in lookbehind assertion can refer only to a group defined 
left. This is likely to change in the future, which brings us to the problem of 
incompatibility.

There are several quick ways to resolve the problem:

1) Rollback the patch and return to the previous non-working behavior. Because 
of the obvious non-working the problem with changing the implementation of 
lookbehind assertion in the future will be weaker.

2) Rollback the patch and emit a warning or error when using any group 
references in lookbehind assertion. Something like patch proposed by Greg 
Chapman in issue814253 (but slightly more advanced).

3) Leave the patch and emit a warning or an error when using group references 
to the group defined in this same lookbehind assertion. Group references will 
work in lookbehind assertions in most cases except rare cases when current re 
behavior differs from regex behavior.

What is your decision Benjamin?

Here is a patch against 2.7 which implements variant 3.

----------
nosy: +benjamin.peterson, larry
priority: normal -> release blocker
resolution: fixed -> 
stage: resolved -> 
status: closed -> open
Added file: 
http://bugs.python.org/file37324/re_forbid_some_groupref_in_lookbehind-2.7.patch

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

Reply via email to