[issue19449] csv.DictWriter can't handle extra non-string fields

2013-11-19 Thread R. David Murray
R. David Murray added the comment: Thanks, Tomas and Vajrasky. I tweaked the patch slightly: Thomas's fix was better, since it doesn't incur the overhead of the repr unless an an error is detected (a micro-optimization, true, but an easy one). I also chose to only check that 'fieldnames' is

[issue19449] csv.DictWriter can't handle extra non-string fields

2013-11-19 Thread Roundup Robot
Roundup Robot added the comment: New changeset 6e5afeada7ca by R David Murray in branch '3.3': #19449: Handle non-string keys when generating 'fieldnames' error. http://hg.python.org/cpython/rev/6e5afeada7ca New changeset ee2c80eeca2a by R David Murray in branch 'default': Merge: #19449: Handle

[issue19449] csv.DictWriter can't handle extra non-string fields

2013-11-12 Thread Vajrasky Kok
Changes by Vajrasky Kok : -- components: +Library (Lib) versions: +Python 3.3, Python 3.4 -Python 2.6 ___ Python tracker ___ ___ Pytho

[issue19449] csv.DictWriter can't handle extra non-string fields

2013-11-12 Thread Vajrasky Kok
Vajrasky Kok added the comment: Here is the preliminary patch. -- nosy: +vajrasky Added file: http://bugs.python.org/file32582/fix_error_message_write_fields_not_in_fieldnames.patch ___ Python tracker

[issue19449] csv.DictWriter can't handle extra non-string fields

2013-10-30 Thread R. David Murray
R. David Murray added the comment: > But why should the field names have to be strings in the first place? > Everything else is passed through str before being written anyway... Good point. -- ___ Python tracker

[issue19449] csv.DictWriter can't handle extra non-string fields

2013-10-30 Thread Tomas Grahn
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 is passed th

[issue19449] csv.DictWriter can't handle extra non-string fields

2013-10-30 Thread R. David Murray
R. David Murray added the comment: Rereading my post I disagree with myself. ValueError is probably better in this context (the difference between ValueError and TypeError is a bit grey, and Python is not necessarily completely consistent about it.) -- ___

[issue19449] csv.DictWriter can't handle extra non-string fields

2013-10-30 Thread R. David Murray
R. David Murray added the comment: I would argue that the TypeError is correct (field names must be strings), even though the way it is generated is a bit unorthodox :) Let's see what others think. -- nosy: +r.david.murray ___ Python tracker

[issue19449] csv.DictWriter can't handle extra non-string fields

2013-10-30 Thread Tomas Grahn
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 contains fields not