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 xflr6
Recipients Aldrian Obaja, Alex Shpilkin, Apathymannequin, Dmitriy Shashkin, avatarofhope, berker.peksag, catalin.iacob, ebreck, eric.araujo, taleinat, xflr6
Date 2021-07-13.19:26:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1626204366.25.0.657157262639.issue12178@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2021-07-13 19:26:06xflr6setrecipients: + xflr6, taleinat, eric.araujo, catalin.iacob, ebreck, berker.peksag, Apathymannequin, Dmitriy Shashkin, Alex Shpilkin, avatarofhope, Aldrian Obaja
2021-07-13 19:26:06xflr6setmessageid: <1626204366.25.0.657157262639.issue12178@roundup.psfhosted.org>
2021-07-13 19:26:06xflr6linkissue12178 messages
2021-07-13 19:26:06xflr6create