-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-featureA feature request or enhancementA feature request or enhancement
Description
I dislike PyList_New() + PyList_SET_ITEM() API since the list is immediately tracked by the GC and so calling gc.get_objects() can expose an invalid list object (ex: calling repr(list) can crash). See:
- Disallow creation of incomplete/inconsistent objects capi-workgroup/problems#56
- gh-107137: Add _PyTupleBuilder API to the internal C API #107139
- Avoid creating incomplete/invalid objects capi-workgroup/api-evolution#36
The internal PyObject * _PyTuple_FromArray(PyObject *const *src, Py_ssize_t n) function should be made public.
UPDATE: I updated the issue to request promoting _PyTuple_FromArray() instead of _PyList_FromArraySteal().
Linked PRs
erlend-aasland
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-featureA feature request or enhancementA feature request or enhancement