Closed xflr6 closed 6 years ago
>>> import csv >>> from csvw.dsv import UnicodeWriter, UnicodeReader >>> kwargs = {'quoting': csv.QUOTE_NONE, 'escapechar': '\\'} >>> row = ['\\spam'] >>> with UnicodeWriter(**kwargs) as writer: writer.writerow(row) >>> writer.f.seek(0) 0 >>> with UnicodeReader(writer.f, **kwargs) as reader: result = next(reader) >>> assert result == row Traceback (most recent call last): ... AssertionError >>> result ['\\\\spam']
https://bugs.python.org/issue12178 only occurs with quoting dialects, so our workaround for it _escapedoubled() needs to be restricted to those dialects: https://github.com/cldf/csvw/blob/ecc8e74b53c7478b83d32d1c0fc19e2df4c7288f/csvw/dsv.py#L99-L109
_escapedoubled()
See also https://github.com/cldf/csvw/blob/master/tests/test_csv_escapechar.py
https://bugs.python.org/issue12178 only occurs with quoting dialects, so our workaround for it
_escapedoubled()
needs to be restricted to those dialects: https://github.com/cldf/csvw/blob/ecc8e74b53c7478b83d32d1c0fc19e2df4c7288f/csvw/dsv.py#L99-L109