Bug description:
A list and tuple have some problems as shown below:
*Problems:
- A negative index is possible to use so it should be impossible to use. *I've never used it in my life.
- Slicing doesn't get
index out of range error while indexing gets it so slicing should also get index out of range error.
- For slicing, the left index can be greater than the right index, e.g.
[10:-10] so they shouldn't be like that.
<List indexing>:
v = ['A', 'B', 'C', 'D', 'E']
print(v[2], v[-3])
# C C
print(v[-10], v[10])
# IndexError: list index out of range
<Tuple indexing>:
v = ('A', 'B', 'C', 'D', 'E')
print(v[2], v[-3])
# C C
print(v[-10], v[10])
# IndexError: tuple index out of range
<List slicing>:
v = ['A', 'B', 'C', 'D', 'E']
print(v[2], v[-3])
# C C
print(v[-10:10]) # No error
# ['A', 'B', 'C', 'D', 'E']
print(v[10:-10]) # No error
# []
<Tuple slicing>:
v = ('A', 'B', 'C', 'D', 'E')
print(v[2], v[-3])
# C C
print(v[-10:10]) # No error
# ('A', 'B', 'C', 'D', 'E')
print(v[10:-10]) # No error
# []
CPython versions tested on:
3.12
Operating systems tested on:
Windows