Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: inconsistent line endings #200

Closed
radoering opened this issue Jun 18, 2022 · 0 comments · Fixed by #201
Closed

Regression: inconsistent line endings #200

radoering opened this issue Jun 18, 2022 · 0 comments · Fixed by #201

Comments

@radoering
Copy link
Member

#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")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant