New submission from Eric V. Smith <e...@trueblade.com>:
Currently, the csv library calls str() on each value it writes. This can lead to surprising behavior, see issue40762 for example. On the other hand, for writing the documentation says that the values must be strings or numbers. The proposed "strict" argument would raise a TypeError if the supplied values are not strings, numbers, or None. See https://github.com/python/cpython/blob/ba1c2c85b39fbcb31584c20f8a63fb87f9cb9c02/Modules/_csv.c#L1203 for where str() is called. The documentation should be changed to note that None is allowed. Currently, None results in an empty string. I'm not proposing to change this, just document it as one of the allowed types. How to check for "value is a number" needs to be decided. ---------- messages: 370380 nosy: eric.smith priority: normal severity: normal status: open title: Add a "strict" parameter to csv.writer and csv.DictWriter type: enhancement versions: Python 3.10 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40825> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com