Message369866
Yes, I do recognise that the current doc states that csv only supports strings and numbers.
However the use case here is motivated when the user wants to write bytes and numbers/strings mixed to a CSV file. Currently providing bytes to write to a CSV passes it through str() as you stated, however this results it into being being prefixed with a b. Ex. "b'A'" is written instead of "A".
This kind of output is in most real-life cases not useful for any other program (be it python or non-python) that ends up reading this csv file, since this CSV file consists of a Python-specific syntax.
As an example, if I write character "A" as a byte, i.e b'A' in a csv file, it will end up writing "b'A'", which is not what the user would have wanted in majority of the use-cases.
Another way to change this behaviour could be to redefine how str() method works on bytes in python so that python doesn't leak out this b-prefix notation in generic file systems (ex. CSV), however that is too fundamental of a change and will affect the entire codebase in large. |
|
| Date |
User |
Action |
Args |
| 2020-05-25 09:15:37 | sidhant | set | recipients:
+ sidhant, serhiy.storchaka |
| 2020-05-25 09:15:37 | sidhant | set | messageid: <1590398137.56.0.450644457861.issue40762@roundup.psfhosted.org> |
| 2020-05-25 09:15:37 | sidhant | link | issue40762 messages |
| 2020-05-25 09:15:37 | sidhant | create | |
|