Skip to content

csv.writer: embedded \r/\n not quoted with a custom lineterminator (QUOTE_MINIMAL) #8317

Description

@jinmay

Feature

Follow-up from #8254 (found by @doma17).

With QUOTE_MINIMAL and a custom lineterminator (not CR/LF), embedded \r/\n in a field are not quoted, so the output differs from CPython.

import csv, io
sio = io.StringIO()
csv.writer(sio, lineterminator="!").writerow(["\r", "\n"])
print(repr(sio.getvalue()))
# CPython:    '"\r","\n"!'
# RustPython: '\r,\n!'

CPython always quotes fields containing \r/\n regardless of the lineterminator. (Not a regression from #8254 — same on develop.)

Python Documentation or reference to CPython source code

https://docs.python.org/3/library/csv.html#csv.QUOTE_MINIMAL


Re-created from #8302, which was closed by accident.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions