http://bugs.python.org/review/25953/diff/18873/Lib/sre_parse.py
File Lib/sre_parse.py (right):
http://bugs.python.org/review/25953/diff/18873/Lib/sre_parse.py#newcode888
Lib/sre_parse.py:888: raise error("invalid group reference %r" % index)
It would be better to use s.error(). This helper sets the pattern attribute and
the position of error. If raise an error not inside addgroup(), but before
calling it, it would be possible to set correct position.
There are other "invalid group reference" errors. They don't include index. It
should be either included in all similar errors or in no one.
https://bugs.python.org/review/25953/diff/18937/Lib/test/test_re.py
File Lib/test/test_re.py (right):
https://bugs.python.org/review/25953/diff/18937/Lib/test/test_re.py#newcode277
Lib/test/test_re.py:277: 'invalid group reference 2', 2)
On 2016/10/22 14:37:00, storchaka wrote:
> The position is wrong. It should point at the start of group name/index
(compare
> with above tests), i.e. be equal to 1 here.
The above tests (lines 189-201) have position equal 2. Is that also not correct
there? Or are you referring to the lines 263-275? (but then I'm not sure why
they'd be relevant here).
https://bugs.python.org/review/25953/diff/18937/Lib/test/test_re.py
File Lib/test/test_re.py (right):
https://bugs.python.org/review/25953/diff/18937/Lib/test/test_re.py#newcode277
Lib/test/test_re.py:277: 'invalid group reference 2', 2)
On 2016/10/22 15:04:59, SilentGhost wrote:
> On 2016/10/22 14:37:00, storchaka wrote:
> > The position is wrong. It should point at the start of group name/index
> (compare
> > with above tests), i.e. be equal to 1 here.
> The above tests (lines 189-201) have position equal 2. Is that also not
correct
> there?
Yes, they are not correct too.
> Or are you referring to the lines 263-275? (but then I'm not sure why
> they'd be relevant here).
Tests at lines 263-275 have correct positions. Invalid group reference 2 starts
at position 3 in pattern r'\g<2>' and at position 1 in pattern r'\2'.