Skip to content

[bug] get_slice_items fails with negative step #746

@jgirardet

Description

@jgirardet

I was struggling adding getitem to bytes using get_slice_items but it appears to also fails with string:

jimmy@x-or:~/trash/RustPython$ cargo run -- -c "print('result : ', 'abcd'[-1:-5:-1])"
    Finished dev [unoptimized + debuginfo] target(s) in 0.23s                                                                                                                                     
     Running `target/debug/rustpython -c 'print('\''result : '\'', '\''abcd'\''[-1:-5:-1])'`
result :  
jimmy@x-or:~/trash/RustPython$ python -c "print('result : ', 'abcd'[-1:-5:-1])"                                                                                                                    
result :  dcba

and list :

jimmy@x-or:~/trash/RustPython$ python -c "print('result : ', [1,2,3,5,6][-1:-5:-1])"                                                                                                              
result :  [6, 5, 3, 2]
jimmy@x-or:~/trash/RustPython$ cargo run -- -c "print('result : ', [1,2,3,5,6][-1:-5:-1])"                                                                                                         
    Finished dev [unoptimized + debuginfo] target(s) in 0.41s                                                                                                                                     
     Running `target/debug/rustpython -c 'print('\''result : '\'', [1,2,3,5,6][-1:-5:-1])'`
result :  []

I can"t tell what's wrong for now

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions