[3.14] gh-146056: Fix repr() for lists and tuples containing NULLs (GH-146129) by serhiy-storchaka · Pull Request #146155 · python/cpython
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the Python code base, if I read the code correctly, only tuple_repr() can call PyUnicodeWriter_WriteRepr() with NULL. For example, list_repr() cannot pass NULL, because item = Py_NewRef(v->ob_item[i]) crash if the item is NULL.
And what about the user code? We leave it with a mine which explodes in rare and most likely not tested case.
My concern is that if you develop on (the future) Python 3.14.4 with PyUnicodeWriter_WriteRepr() which accepts NULL, you can get crashes if an user uses Python 3.14.0 which doesn't accept NULL. I don't think that it's a good idea to change the API in a 3.14.x bugfix release.