[issue25953] re fails to identify invalid numeric group references in replacement strings

2017-03-31 Thread Donald Stufft

Changes by Donald Stufft :


--
pull_requests: +892

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25953] re fails to identify invalid numeric group references in replacement strings

2016-10-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Committed with additional changes. Fixed yet one occurrence of "invalid group 
reference" without group index, and made small style changes.

--
resolution:  -> fixed
stage: commit review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25953] re fails to identify invalid numeric group references in replacement strings

2016-10-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset cea983246919 by Serhiy Storchaka in branch '3.6':
Issue #25953: re.sub() now raises an error for invalid numerical group
https://hg.python.org/cpython/rev/cea983246919

New changeset 15e3695affa2 by Serhiy Storchaka in branch 'default':
Issue #25953: re.sub() now raises an error for invalid numerical group
https://hg.python.org/cpython/rev/15e3695affa2

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25953] re fails to identify invalid numeric group references in replacement strings

2016-10-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

LGTM. Thank you for your contribution SilentGhost.

--
stage: patch review -> commit review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25953] re fails to identify invalid numeric group references in replacement strings

2016-10-23 Thread SilentGhost

SilentGhost added the comment:

Updated patch fixing the position issue.

--
Added file: http://bugs.python.org/file45194/25953_5.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25953] re fails to identify invalid numeric group references in replacement strings

2016-10-22 Thread SilentGhost

SilentGhost added the comment:

I've modified addgroup to take a pos argument, this seem to introduce minimal 
disturbance.

--
Added file: http://bugs.python.org/file45187/25953_4.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25953] re fails to identify invalid numeric group references in replacement strings

2016-10-20 Thread SilentGhost

SilentGhost added the comment:

Updated patch taking Serhiy's comments into account.

There was another case on line 725 for when zero is used as a group number, I'm 
not sure though if it falls within the scope of this issue, so it's not 
included in the current patch.

--
versions:  -Python 3.5
Added file: http://bugs.python.org/file45158/25953_3.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25953] re fails to identify invalid numeric group references in replacement strings

2016-10-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Needed new tests for changed behavior. Test re.sub() with incorrect groups and 
the string that doesn't match the pattern (e.g. empty string).

Added other comments on Rietveld.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25953] re fails to identify invalid numeric group references in replacement strings

2016-10-16 Thread SilentGhost

SilentGhost added the comment:

Here is the updated patch with fixes to the test suite.

--
versions: +Python 3.7
Added file: http://bugs.python.org/file45113/25953_2.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25953] re fails to identify invalid numeric group references in replacement strings

2016-10-16 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka
nosy: +serhiy.storchaka
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25953] re fails to identify invalid numeric group references in replacement strings

2015-12-25 Thread bazwal

New submission from bazwal:

This code example:

re.sub(r'(?P[123])', r'\g', '')

will correctly raise a KeyError due to the invalid group reference.

However, this very similar code example:

re.sub(r'(?P[123])', r'\g<3>', '')

fails to raise an error. It seems that the only way to check whether a numeric 
group reference is compatible with a given pattern is to test it against a 
string which happens to match. But this is obviously infeasible when checking 
unknown expressions (e.g. those taken from user input). And in any case: errors 
should be raised at the point where they occur (i.e. during compilation), not 
at some indeterminate point in the future.

Regular expression objects have a "groups" attribute which holds the number of 
capturing groups in the pattern. So there seems no good reason why the 
replacement string parser can't identify invalid numeric group references in 
exactly the same way that it does for symbolic ones.

--
components: Regular Expressions
messages: 257008
nosy: bazwal, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: re fails to identify invalid numeric group references in replacement 
strings
type: behavior
versions: Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25953] re fails to identify invalid numeric group references in replacement strings

2015-12-25 Thread SilentGhost

SilentGhost added the comment:

Well, at least on the surface of it, the fix seems pretty straightforward:
check for the group index. With this patch the behaviour is as expected, but I 
get two tests erroring out since they're expecting differently worded error. 
This probably needs adjustments to those tests as well as C code written.

--
keywords: +patch
nosy: +SilentGhost
versions: +Python 3.6
Added file: http://bugs.python.org/file41422/issue25953.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com