Bug report
Bug description:
The complex-total fast path in builtin_sum_impl (Python/bltinmodule.c:3049) guards with PyFloat_Check(item) (accepts subclasses) but frees the item with _Py_DECREF_SPECIALIZED(item, _PyFloat_ExactDealloc)`, which assumes an exact float.
Reproducer:
class F(float):
def __del__(self):
print("__del__ ran")
sum((F(x) for x in (2.0, 3.0)), 1j) # generator so refcount hits 0
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Bug report
Bug description:
The complex-total fast path in
builtin_sum_impl(Python/bltinmodule.c:3049) guards withPyFloat_Check(item)(accepts subclasses) but frees the item with _Py_DECREF_SPECIALIZED(item, _PyFloat_ExactDealloc)`, which assumes an exact float.Reproducer:
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs