Skip to content

Less descriptive error message when index not in list item in Python 3.14 #140819

@DanielYang59

Description

@DanielYang59

Bug report

Bug description:

It looks like in Python 3.14 the error message became less descriptive when indexing a non-existent item in list:

>>> uv run -p 3.13 python -c '["a"].index(1)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    ["a"].index(1)
    ~~~~~~~~~~~^^^
ValueError: 1 is not in list

>>> uv run -p 3.14 python -c '["a"].index(1)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    ["a"].index(1)
    ~~~~~~~~~~~^^^
ValueError: list.index(x): x not in list

In 3.13 it's directly obvious 1 is not in list, and in Python 3.14 it refers to x where x is not even defined

CPython versions tested on:

3.14

Operating systems tested on:

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions