Skip to content
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

__getslice__ changes integer arguments #44925

Closed
lorgandon mannequin opened this issue May 3, 2007 · 3 comments
Closed

__getslice__ changes integer arguments #44925

lorgandon mannequin opened this issue May 3, 2007 · 3 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@lorgandon
Copy link
Mannequin

lorgandon mannequin commented May 3, 2007

BPO 1712236
Nosy @rhettinger
Files
  • bug_example.txt: An example reproducing the bug.
  • 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:

    assignee = None
    closed_at = <Date 2007-05-18.23:51:44.000>
    created_at = <Date 2007-05-03.18:20:45.000>
    labels = ['interpreter-core']
    title = '__getslice__ changes integer arguments'
    updated_at = <Date 2007-05-18.23:51:44.000>
    user = 'https://bugs.python.org/lorgandon'

    bugs.python.org fields:

    activity = <Date 2007-05-18.23:51:44.000>
    actor = 'rhettinger'
    assignee = 'none'
    closed = True
    closed_date = None
    closer = None
    components = ['Interpreter Core']
    creation = <Date 2007-05-03.18:20:45.000>
    creator = 'lorgandon'
    dependencies = []
    files = ['2367']
    hgrepos = []
    issue_num = 1712236
    keywords = []
    message_count = 3.0
    messages = ['31941', '31942', '31943']
    nosy_count = 2.0
    nosy_names = ['rhettinger', 'lorgandon']
    pr_nums = []
    priority = 'normal'
    resolution = 'wont fix'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1712236'
    versions = []

    @lorgandon
    Copy link
    Mannequin Author

    lorgandon mannequin commented May 3, 2007

    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.

    @lorgandon lorgandon mannequin closed this as completed May 3, 2007
    @lorgandon lorgandon mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label May 3, 2007
    @lorgandon lorgandon mannequin closed this as completed May 3, 2007
    @lorgandon lorgandon mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label May 3, 2007
    @lorgandon
    Copy link
    Mannequin Author

    lorgandon mannequin commented May 3, 2007

    This also seems to be the cause of bug "[ 908441 ] default index for __getslice__ is not sys.maxint"

    @rhettinger
    Copy link
    Contributor

    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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant