Skip to content

Preserve LF stdin output on Windows - #2616

Open
AleksZyro wants to merge 1 commit into
PyCQA:mainfrom
AleksZyro:issue/2453
Open

Preserve LF stdin output on Windows#2616
AleksZyro wants to merge 1 commit into
PyCQA:mainfrom
AleksZyro:issue/2453

Conversation

@AleksZyro

Copy link
Copy Markdown

Refs #2453.

When sorting stdin to stdout on Windows, Python's text-mode stdout can translate \n to \r\n. That makes LF input become CRLF output even when isort inferred LF from the input stream.

This writes stdin sorting output through a stdout wrapper with newline translation disabled, and adds a regression test for LF input written through a text stdout stream.

Tested with:

python -m pytest tests/unit/test_main.py::test_isort_with_stdin_preserves_lf_stdout -q
python -m pytest tests/unit/test_main.py::test_isort_with_stdin -q
python -m ruff check isort/main.py tests/unit/test_main.py
python -m ruff format --check isort/main.py tests/unit/test_main.py

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.

1 participant