Tomas Grahn added the comment:
If non-string field names aren't allowed then shouldn't they be caught at an
earlier stage, rather then when the user feeds writerow a dict with an
unexpected key?
But why should the field names have to be strings in the first place?
Everything else
New submission from Tomas Grahn:
When csv.DictWriter.writerow is fed a dict with extra fieldnames (and
extrasaction='raise') and any of those extra fieldnames aren't strings, a
TypeError-exception is thrown. To fix the issue; in csv.py, edit the line:
raise ValueError("dict