[Python-checkins] python/nondist/sandbox/csv csv.py,1.29,1.30
montanaro@users.sourceforge.net
montanaro@users.sourceforge.net
Tue, 11 Feb 2003 06:13:28 -0800
Update of /cvsroot/python/python/nondist/sandbox/csv
In directory sc8-pr-cvs1:/tmp/cvs-serv22594
Modified Files:
csv.py
Log Message:
fix bad test of dict keys against fieldnames
Index: csv.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/csv/csv.py,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** csv.py 10 Feb 2003 22:45:21 -0000 1.29
--- csv.py 11 Feb 2003 14:13:25 -0000 1.30
***************
*** 86,91 ****
dialect="excel", *args):
self.fieldnames = fieldnames # list of keys for the dict
- self._fnsort = fieldnames[:]
- self._fnsort.sort()
self.restval = restval # for writing short dicts
if extrasaction.lower() not in ("raise", "ignore"):
--- 86,89 ----
***************
*** 97,105 ****
def _dict_to_list(self, rowdict):
! keys = rowdict.keys()
! keys.sort()
! if keys != self._fnsort:
! if self.extrasaction == "raise":
! raise ValueError, "dict contains fields not in fieldnames"
return [rowdict.get(key, self.restval) for key in self.fieldnames]
--- 95,102 ----
def _dict_to_list(self, rowdict):
! if self.extrasaction == "raise":
! for k in rowdict.keys():
! if k not in self.fieldnames:
! raise ValueError, "dict contains fields not in fieldnames"
return [rowdict.get(key, self.restval) for key in self.fieldnames]