Skip to content

csv.writer: multi-character lineterminator is truncated to a single byte #8322

Closed

Description

@jinmay

Feature

Follow-up from #8302 / #8315.

csv.writer should accept an arbitrary string as lineterminator. RustPython stores it as a single byte, so a multi-character terminator is truncated instead of being emitted in full.

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

Because of this, test_write_lineterminator (Lib/test/test_csv.py) is marked @unittest.expectedFailure — it fails only on the '!@#' subcase.

Scope is limited to the multi-character lineterminator. Left as separate follow-ups: lineterminator validation parity, non-ASCII delimiter/quotechar/escapechar (see #8310), and reader semantics (CPython's reader ignores lineterminator and only recognizes CR/LF).

Python Documentation or reference to CPython source code

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

Drafted with AI assistance (Claude Code), reviewed by me.

Activity

  1. jinmay commented on Jul 19, 2026

    @jinmay
    ContributorAuthor

    take

  2. changed the title [-]csv: support multi-character lineterminator in writer[/-] [+]csv.writer: multi-character lineterminator is truncated to a single byte[/+] on Jul 19, 2026
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