diff -r 9e61563edb67 Lib/csv.py --- a/Lib/csv.py Sun Aug 11 16:48:44 2013 -0700 +++ b/Lib/csv.py Wed Aug 14 21:14:30 2013 -0700 @@ -143,7 +143,8 @@ def _dict_to_list(self, rowdict): if self.extrasaction == "raise": - wrong_fields = [k for k in rowdict if k not in self.fieldnames] + fieldset = set(self.fieldnames) + wrong_fields = [k for k in rowdict if k not in fieldset] if wrong_fields: raise ValueError("dict contains fields not in fieldnames: " + ", ".join(wrong_fields))