Author ezio.melotti
Recipients docs@python, ezio.melotti, mrabarnett, rhettinger, serhiy.storchaka, timehorse, tlynn
Date 2019-07-14.14:01:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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), 'abcde'[s:e]
(['b', 'c', 'd'], 'bcd')
>>> s, e = -4, 4; re.compile('.').findall('abcde', s, e), 'abcde'[s:e]
(['a', 'b', 'c', 'd'], 'bcd')
>>> s, e = 1, -1; re.compile('.').findall('abcde', s, e), 'abcde'[s:e]
([], 'bcd')
>>> s, e = -4, -1; re.compile('.').findall('abcde', s, e), 'abcde'[s:e]
([], 'bcd')

With the patch, all these return ['b', 'c', 'd'].  This change might indeed cause issues because it's a change in behavior, but I'm also not sure there are many cases where one would want a negative index to be treated as 0.  Maybe we could raise a FutureWarning in the next release and change the behavior afterwards?
Date User Action Args
2019-07-14 14:01:58ezio.melottisetrecipients: + ezio.melotti, rhettinger, tlynn, timehorse, mrabarnett, docs@python, serhiy.storchaka
2019-07-14 14:01:58ezio.melottisetmessageid: <>
2019-07-14 14:01:58ezio.melottilinkissue7940 messages
2019-07-14 14:01:58ezio.melotticreate