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

fix: Windows double line spacing fix #27

Merged
merged 1 commit into from
Feb 2, 2021

Conversation

henryiii
Copy link
Contributor

@henryiii henryiii commented Jan 29, 2021

The current version does not work on Windows, as reported by @pfmoore in pypa/pip#9462. Files opened in text mode should not have the native line ending applied - Python normalizes this for you. Quick demo of problem:

from pathlib import Path
from os import linesep

txt = Path("tmp.txt")
with txt.open("w", encoding="utf-8") as f:
    f.writelines(f"{p}{linesep}" for p in range(3))
with txt.open(encoding="utf-8") as f:
    print(f.read())

This produces empty lines between outputs, but only Windows (due to the separator there).

Had to find and boot up an old Windows box to verify that demo. 😠

The current version does not work on Windows, as reported by @pfmoore in pypa/pip#9462. Files opened in text mode should not have the native line ending applied - Python normalizes this for you. Quick demo of problem:

```python
from pathlib import Path
from os import linesep

txt = Path("tmp.txt")
with txt.open("w", encoding="utf-8") as f:
    f.writelines(f"{p}{linesep}" for p in range(3))
with txt.open(encoding="utf-8") as f:
    print(f.read())
```

Produces empty lines between outputs, but only Windows (due to the separator there).
@pradyunsg pradyunsg merged commit b110ec5 into pradyunsg:master Feb 2, 2021
@pradyunsg
Copy link
Owner

Thanks for the PR! ^>^

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 this pull request may close these issues.

2 participants