This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author sidhant
Recipients sidhant
Date 2020-05-25.05:52:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1590385965.26.0.776007831403.issue40762@roundup.psfhosted.org>
In-reply-to
Content
The following code
```
import csv
with open("abc.csv", "w") as f:
   data = [b'\xc2a9', b'\xc2a9']
   w = csv.writer(f)
   w.writerow(data)
```
writes "b'\xc2a9',b'\xc2a9'" in "abc.csv", i.e the b-prefixed byte string instead of the actual bytes. 

Although one can argue that the write is done in text mode and not binary mode, however I believe the more natural expectation by the user will be to have the bytes written actually in the "abc.csv". Also take note that writing in binary mode is not supported by csv, so the only method to write bytes is this.

Can refer to this https://github.com/pandas-dev/pandas/issues/9712 to see one of the issues this brings in Pandas. From the discussion on this issue, the main reasons of changing this behaviour in Python would be to avoid leaking python's encoding system syntax into a generic data exchange format, i.e CSV.
History
Date User Action Args
2020-05-25 05:52:45sidhantsetrecipients: + sidhant
2020-05-25 05:52:45sidhantsetmessageid: <1590385965.26.0.776007831403.issue40762@roundup.psfhosted.org>
2020-05-25 05:52:45sidhantlinkissue40762 messages
2020-05-25 05:52:45sidhantcreate