[issue31984] startswith and endswith leak implementation details

2017-11-08 Thread Steven D'Aprano
Steven D'Aprano added the comment: I don't have Python 3.7 available to me, but in 3.5 the behaviour of u.startswith(v) with an empty v seems consistent to me: py> "alpha".startswith("", 20, 30) True py> "alpha"[20:30].startswith("") True py> "".startswith("", 20, 30) True py> ""[20:30].star

[issue31984] startswith and endswith leak implementation details

2017-11-08 Thread Steven D'Aprano
Steven D'Aprano added the comment: Thank you for the bug report Ronan, but I'm afraid that I have no idea what you think the problematic behaviour is. I'm not going to spend the time installing the third-party hypothesis module, and learning how to use it, just to decipher your "actual spec".

[issue31984] startswith and endswith leak implementation details

2017-11-08 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: For the justification of the find() behavior see msg243668. But the largest argument for this behavior is that find() have it for a long time. Changing it will break existing code that depends on it. This argument is weaker in the case of startwith() and en

[issue31984] startswith and endswith leak implementation details

2017-11-08 Thread Ronan Lamy
Ronan Lamy added the comment: Ah, thanks, I noticed the discrepancy between unicode and str in 2.7, but wondered when it was fixed. I guess I'm arguing that it was resolved in the wrong direction, then. Now, your first expression is wrong, even after fixing the obvious typo. The correct vers

[issue31984] startswith and endswith leak implementation details

2017-11-08 Thread Barry A. Warsaw
Change by Barry A. Warsaw : -- nosy: +barry ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pytho

[issue31984] startswith and endswith leak implementation details

2017-11-08 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: See issue24284. `s1.startswith(s2, start, end)` for non-negative indices and non-tuple s2 is equivalent to expressions start + len(s2) <= end and s2[start: start + len(s2)] == s2 or s1.find(s2, start, end) == start -- nosy: +serhiy.storchak

[issue31984] startswith and endswith leak implementation details

2017-11-08 Thread Ronan Lamy
Ronan Lamy added the comment: The problem is the complexity of the actual behaviour of these methods. It is impossible to get it right without looking at the source (at least, it was for me), and I doubt any ordinary user can correctly make use of the v='' behaviour, or predict what the retu

[issue31984] startswith and endswith leak implementation details

2017-11-08 Thread R. David Murray
R. David Murray added the comment: Can you please give examples of what you think the problem is? -- nosy: +r.david.murray ___ Python tracker ___ __

[issue31984] startswith and endswith leak implementation details

2017-11-08 Thread Ronan Lamy
New submission from Ronan Lamy : One would think that u.startswith(v, start, end) would be equivalent to u[start: end].startswith(v), but one would be wrong. And the same goes for endswith(). Here is the actual spec (for bytes, but str and bytearray are the same), in the form of passing pytest