Skip to content

Regression: inconsistent line endings #200

@radoering

Description

@radoering

#149 introduced a regression especially for Windows users. If your toml file contains only windows line endings ("\r\n"), you may get mixed line endings when you read, change and write the toml file.

Example:

toml_path = str(tmpdir / "pyproject.toml")
with open(toml_path, "wb+") as f:
    f.write(b"a = 1\r\nb = 2\r\n")

f = TOMLFile(toml_path)
content = f.read()
content["c"] = 3
f.write(content)

with open(toml_path, "rb") as f:
    print(f.read())

Output: b'a = 1\r\nb = 2\r\nc = 3\n' (the last line ending is "\n" instead of "\r\n")

Metadata

Metadata

Assignees

No one assigned

    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