[issue23171] csv.writer.writerow() does not accept generator (must be coerced to list)

Jon Dufresne report at bugs.python.org
Tue Jan 6 04:39:45 CET 2015


Jon Dufresne added the comment:

I have created an initial patch such that writerow() now allows generators. I have also added a unit test to demonstrate the fix.

The code now coerces iterators (and generators) to a list, then operates on the result. I would have preferred to simply iterate over the argument, however, there is a special case where the length of the argument is exactly 1. So coercing to a list makes checking the length simpler.

All feedback welcome.

----------
keywords: +patch
Added file: http://bugs.python.org/file37609/csv-gen.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23171>
_______________________________________


More information about the Python-bugs-list mailing list