[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-bugs-list
Subject:    [issue40825] Add a "strict" parameter to csv.writer and csv.DictWriter
From:       Serhiy Storchaka <report () bugs ! python ! org>
Date:       2020-05-31 19:03:35
Message-ID: 1590951815.5.0.697884218574.issue40825 () roundup ! psfhosted ! org
[Download RAW message or body]


Serhiy Storchaka <storchaka+cpython@gmail.com> added the comment:

Yes, converting Decimal to float can lose precision, so we cannot require this. \
PyNumber_Check() is already used for QUOTE_NONNUMERIC, so it would be logical to use \
it in determining that the object is a number in the cvs module.

But now the problem is with determining what is a "string". There is no way to check \
whether the object is "string-like", because virtually all objects can be converted \
to string. The only standard exception is bytes and bytearray for which str() may \
emit BytesWarning, so this conversion is not reliable. If restrict it only to an \
instance of str or its subclasses, it may break other user cases, for example writing \
Path in CVS.

----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue40825>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/python-bugs-list%40marc.info



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic