Python3.14: list.index() raises ValueError with the pre-3.14 message
Bug Description
On Python 3.14, list.index() of a value that is not in the list raises ValueError with the pre-3.14 message. CPython 3.14 changed the message from 9 is not in list to list.index(x): x not in list, but Nuitka's own helper still uses the old one.
The cause is _LIST_INDEX_COMMON in nuitka/build/static_src/HelpersLists.c, which always formats "%R is not in list" on Python 3. The start and stop variant ([1, 9].index(9, 0, 1)) is affected too.
I checked the related messages from the same CPython change. list.remove, tuple.index and deque.index already match CPython 3.14, and so do str.index and bytes.index.
️ Environment
1. Nuitka Version, Python Version, OS, and Platform
4.3rc3
Update status: newer than stable release '4.2.1' (cached, 5 days old).
Commercial: None
Python: 3.14.7 (main, Sep 1 2026, 14:05:28) [Clang 22.1.3 ]
Flavor: Python Build Standalone
GIL: yes
Executable: ~/.local/share/uv/python/cpython-3.14-macos-aarch64-none/bin/python3.14
OS: Darwin
Arch: arm64
macOSRelease: 26.5.2
Version C compiler: clang (clang 21.0.0).This is develop at 4506e7927.
2. How Nuitka and Python were Installed
Python is installed with uv python install. Nuitka is a git checkout of develop.
3. Relevant PyPI Packages and Versions
None.
️ To Reproduce
1. "Hello World" Test (if applicable)
Hello world compiles and runs.
2. Short, Self-Contained, Correct, Eligible (SSCCE) Example
try:
[1].index(9)
except ValueError as e:
print(e)3. Nuitka Command Line Options
python -m nuitka list_index.pyExpected Behavior
This is CPython 3.14's output:
list.index(x): x not in listActual Behavior & Output
9 is not in listOn 3.13, CPython and Nuitka both print 9 is not in list, as expected.
↩️ Regression (if applicable)
This is not a Nuitka regression. The message changed in CPython 3.14.
Additional Context (Optional)
With this change, both index forms match CPython 3.14, and 3.13 keeps the old message. I'm happy to open it as a PR if that's welcome.
SET_CURRENT_EXCEPTION_TYPE0_VALUE1(tstate, PyExc_ValueError, err_string);
return NULL;
-#else
+#elif PYTHON_VERSION < 0x3e0
PyErr_Format(PyExc_ValueError, "%R is not in list", item);
return NULL;
+#else
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError, "list.index(x): x not in list");
+ return NULL;
#endif
}Source: Nuitka/Nuitka