[issue40762] Writing bytes using CSV module results in b prefixed strings

2020-05-25 Thread Sidhant Bansal
Sidhant Bansal added the comment: Hi Remi, I understand your concerns with the current approach to resolve this issue. I would like to propose a new/different change to the way `csv.writer` works. I am putting here the diff of how the updated docs (https://docs.python.org/3/library

[issue40762] Writing bytes using CSV module results in b prefixed strings

2020-05-25 Thread Sidhant Bansal
Sidhant Bansal added the comment: Hi Remi, Currently a code like this: ``` with open("abc.csv", "w", encoding='utf-8') as f: data = [b'\x41'] w = csv.writer(f) w.writerow(data) with open("abc.csv", "r") as f: r

[issue40762] Writing bytes using CSV module results in b prefixed strings

2020-05-25 Thread Sidhant Bansal
Sidhant Bansal added the comment: 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

[issue40762] Writing bytes using CSV module results in b prefixed strings

2020-05-24 Thread Sidhant Bansal
Change by Sidhant Bansal : -- keywords: +patch pull_requests: +19634 stage: -> patch review pull_request: https://github.com/python/cpython/pull/20371 ___ Python tracker <https://bugs.python.org/issu

[issue40762] Writing bytes using CSV module results in b prefixed strings

2020-05-24 Thread Sidhant Bansal
Sidhant Bansal added the comment: 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.cs

[issue40762] Writing bytes using CSV module results in b prefixed strings

2020-05-24 Thread Sidhant Bansal
New submission from Sidhant Bansal : 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.cs