Skip to content

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    z-ca-2026Tag to track Contribution Academy 2026

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions