gh-145105: Fix crash in csv.reader with re-entrant iterator (GH-145106)
When a custom iterator calls next() on the same csv.reader from within __next__, the inner iteration sets self->fields to NULL. The outer iteration then crashes in parse_save_field() by passing NULL to PyList_Append. Add a guard after PyIter_Next() to detect that fields was set to NULL by a re-entrant call, and raise csv.Error instead of crashing.
R
Ramin Farajpour Cami committed
20994b1809f9c162e4cae01a5af08bd492ede9f9
Parent: c29d756
Committed by GitHub <noreply@github.com>
on 4/11/2026, 10:18:02 PM