Message397440
Thanks Tal.
AFAICT there was an undocumented change in behaviour related to this fix.
Python 3.9 quotes values with escapechar:
```
import csv
import io
kwargs = {'escapechar': '\\'}
value = 'spam\\eggs'
print(value)
with io.StringIO() as buf:
writer = csv.writer(buf, **kwargs)
writer.writerow([value])
line = buf.getvalue()
print(line.strip())
with io.StringIO(line) as buf:
reader = csv.reader(buf, **kwargs)
(new_value,), = reader
print(new_value)
spam\eggs
"spam\eggs"
spameggs
```
- quotes escapechar
- fails to double the escapechar (this bug)
Btw, from
https://docs.python.org/3/library/csv.html#csv.QUOTE_MINIMAL
> only quote those fields which contain special characters
> such as delimiter, quotechar or any of the characters in lineterminator.
this seems incorrect because escapechar is not mentioned (but at the same time it says 'such as') and maybe better matching the name 'minimal' (or one might expect 'more' quoting as a better default).
Python 3.10:
https://github.com/python/cpython/blob/5c0eed7375fdd791cc5e19ceabfab4170ad44062/Lib/test/test_csv.py#L207-L208
See also https://github.com/xflr6/csv23/actions/runs/1027687524 |
|
Date |
User |
Action |
Args |
2021-07-13 19:26:06 | xflr6 | set | recipients:
+ xflr6, taleinat, eric.araujo, catalin.iacob, ebreck, berker.peksag, Apathymannequin, Dmitriy Shashkin, Alex Shpilkin, avatarofhope, Aldrian Obaja |
2021-07-13 19:26:06 | xflr6 | set | messageid: <1626204366.25.0.657157262639.issue12178@roundup.psfhosted.org> |
2021-07-13 19:26:06 | xflr6 | link | issue12178 messages |
2021-07-13 19:26:06 | xflr6 | create | |
|