This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: __getslice__ changes integer arguments
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: lorgandon, rhettinger
Priority: normal Keywords:

Created on 2007-05-03 18:20 by lorgandon, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bug_example.txt lorgandon, 2007-05-03 18:20 An example reproducing the bug.
Messages (3)
msg31941 - (view) Author: Imri Goldberg (lorgandon) Date: 2007-05-03 18:20
When using slicing for a sequence object, with a user defined __getslice__ function, the arguments to __getslice__ are changed.
This does not happen when __getslice__is called directly.
Attached is some code that demonstrates the problem.

I checked it on various versions, including my
"Python 2.5.1 (r251:54863, May  2 2007, 16:56:35)", on my Ubuntu machine.

Although __getslice__ is deprecated, there is still usage of the function, and a fix would be useful.
msg31942 - (view) Author: Imri Goldberg (lorgandon) Date: 2007-05-03 18:23
This also seems to be the cause of bug "[ 908441 ] default index for __getslice__ is not sys.maxint"
msg31943 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2007-05-18 23:51
Unfortunately, this is a feature, not a bug.  The relevant code is in Python/ceval.c apply_slice().  Calls to s[a:b] get pre-processed before being handed-off to s.__getslice__.  This behavior has been around so long, that it is almost certain that there is a good body of existing code that relies on the behavior.
History
Date User Action Args
2022-04-11 14:56:24adminsetgithub: 44925
2007-05-03 18:20:45lorgandoncreate