New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
inconsistent behavior of __getslice__ #36642
Comments
The following trace shows what I mean:
>>> help(str.__getslice__)
Help on wrapper_descriptor: __getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
>>> 'ab'[-1]
'b'
>>> 'ab'.__getitem__(-1)
'b'
>>> 'ab'[-2:-1]
'a'
>>> 'ab'.__getslice__(-2,-1)
'' that is, __getslice__ does not add the length of the Note that __getitem__ does it right. This bug may be linked to bug 473985 ('str, __getitem__ |
Logged In: YES Tim, I attached a tiny patch which fixes the behavior for |
Logged In: YES This should NOT be fixed this way, Raymond! The docs are (subtly) wrong. For historical reasons, Maybe the docstring should be fixed. |
Logged In: YES If the docstring fix is still the best way to fix this I am willing to make the |
Logged In: YES Yes, please fix the docstring. |
Logged In: YES Fixed as revision 2.232 on HEAD (after getting it right; bah) and as |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: