summaryrefslogtreecommitdiff
path: root/Lib/csv.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2013-11-19 13:16:20 -0500
committerR David Murray <rdmurray@bitdance.com>2013-11-19 13:16:20 -0500
commit9391e94d40e5b85093a7b458d431a33ee8ef77b4 (patch)
tree5211b35c39deaca6c1d4c65e7af72dbbc332f5ad /Lib/csv.py
parent4f93753f0fbeaf8f0116f28f8121568bc474f4da (diff)
downloadcpython-9391e94d40e5b85093a7b458d431a33ee8ef77b4.tar.gz
#19449: Handle non-string keys when generating 'fieldnames' error.
csv was handling non-string keys fine except for the error message generated when a non-string key was not in 'fieldnames'. Fix by Tomas Grahn, full patch-with-test by Vajrasky Kok (tweaked slightly).
Diffstat (limited to 'Lib/csv.py')
-rw-r--r--Lib/csv.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/csv.py b/Lib/csv.py
index da3bc44e7a..a56eed88c8 100644
--- a/Lib/csv.py
+++ b/Lib/csv.py
@@ -146,7 +146,7 @@ class DictWriter:
wrong_fields = [k for k in rowdict if k not in self.fieldnames]
if wrong_fields:
raise ValueError("dict contains fields not in fieldnames: "
- + ", ".join(wrong_fields))
+ + ", ".join([repr(x) for x in wrong_fields]))
return [rowdict.get(key, self.restval) for key in self.fieldnames]
def writerow(self, rowdict):