[issue7940] re.finditer and re.findall should support negative end positions

2019-09-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Note that changing the current behavior is a breaking change. For example someone can use `pattern.findall(text, curpos-50, curpos+50)` to search in the range ±50 characters from the current position. If negative positions change meaning, this will break a

[issue7940] re.finditer and re.findall should support negative end positions

2019-09-09 Thread Zachary Ware
Zachary Ware added the comment: Ezio requested further opinions, so here's mine. I don't think the current behavior makes sense; I doubt anyone actually expects a negative index to be squashed to 0, especially for endpos. I'm not certain that allowing negative indexes is really necessary,

[issue7940] re.finditer and re.findall should support negative end positions

2019-07-15 Thread Ezio Melotti
Ezio Melotti added the comment: > Are there any real world examples which show the benefit of supporting > negative indices? A common case is ignoring parentheses at the beginning/end, e.g. >>> re.compile('[^,]+').findall('(foo,123,(),bar)') ['(foo', '123', '()', 'bar)'] >>> # ignore the

[issue7940] re.finditer and re.findall should support negative end positions

2019-07-15 Thread M. Anil Tuncel
M. Anil Tuncel added the comment: I guess the use of negative indices serve the same purpose here as in lists or strings. Though as Ezio pointed out, the current behaviour is already accepting negative indices but providing inconsistent results in comparison to various other Python modules

[issue7940] re.finditer and re.findall should support negative end positions

2019-07-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Are there any real world examples which show the benefit of supporting negative indices? -- ___ Python tracker ___

[issue7940] re.finditer and re.findall should support negative end positions

2019-07-14 Thread Ezio Melotti
Ezio Melotti added the comment: Sorry, I was wrong. re.findall accepts negative indices for both start and end but they silently get converted to 0, which is arguably an unexpected behavior. This is an example of the current behavior: >>> s, e = 1, 4; re.compile('.').findall('abcde', s, e),

[issue7940] re.finditer and re.findall should support negative end positions

2019-07-14 Thread Ezio Melotti
Ezio Melotti added the comment: The current behavior is inconsistent because the start position accepts both positive and negative indices, whereas the end position only accepts positive indices. I think the proposal and the PR written by Anil are reasonable and should be merged.

[issue7940] re.finditer and re.findall should support negative end positions

2019-07-13 Thread Raymond Hettinger
Raymond Hettinger added the comment: -1 on the proposal. We don't know of any strong use cases, so there isn't a real problem being solved here. Rather than providing a benefit, this feature request makes it more likely that people will write convoluted code or that it will let bugs pass

[issue7940] re.finditer and re.findall should support negative end positions

2019-07-13 Thread Roundup Robot
Change by Roundup Robot : -- pull_requests: +14540 pull_request: https://github.com/python/cpython/pull/14744 ___ Python tracker ___

[issue7940] re.finditer and re.findall should support negative end positions

2014-10-23 Thread Serhiy Storchaka
Changes by Serhiy Storchaka storch...@gmail.com: -- components: +Regular Expressions priority: normal - low stage: needs patch - patch review versions: +Python 3.5 -Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7940

[issue7940] re.finditer and re.findall should support negative end positions

2014-02-03 Thread Mark Lawrence
Changes by Mark Lawrence breamore...@yahoo.co.uk: -- nosy: -BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7940 ___ ___

[issue7940] re.finditer and re.findall should support negative end positions

2013-05-26 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I'm worrying about backward compatibility. See also issue7951. -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7940 ___

[issue7940] re.finditer and re.findall should support negative end positions

2013-05-26 Thread Matthew Barnett
Matthew Barnett added the comment: Like the OP, I would've expected it to handle negative indexes the way that strings do. In practice, I wouldn't normally provide negative indexes; I'd use some string or regex method to determine the search limits, and then pass them to finditer and

[issue7940] re.finditer and re.findall should support negative end positions

2013-05-25 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- components: +Library (Lib) stage: test needed - needs patch versions: +Python 3.4 -Python 2.7, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7940

[issue7940] re.finditer and re.findall should support negative end positions

2013-05-25 Thread Matthew Barnett
Matthew Barnett added the comment: I've attached a patch. -- keywords: +patch Added file: http://bugs.python.org/file30377/issue7940.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7940

[issue7940] re.finditer and re.findall should support negative end positions

2013-05-23 Thread Mark Lawrence
Mark Lawrence added the comment: Has this been fixed in the regex module? -- nosy: +BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7940 ___

[issue7940] re.finditer and re.findall should support negative end positions

2013-05-23 Thread Matthew Barnett
Matthew Barnett added the comment: Yes. As msg99456 suggests, I fixed it the my source code before posting. Compare re in Python 3.3.2: re.compile('x').findall('', 1, 3) ['x', 'x'] re.compile('x').findall('', 1, -1) [] with regex: regex.compile('x').findall('', 1, 3) ['x',