Skip to content

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

Closed

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.

Activity

  1. jinmay commented on Jul 18, 2026

    @jinmay
    ContributorAuthor

    take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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