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

upgrade_pythoncapi: try to preserve newlines when patching #141

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lazka
Copy link

@lazka lazka commented Apr 7, 2025

In case we use \n on Windows or \r\n on Linux we don't want patching files to change every line due to newlines being adjusted to the platform defaults.

Instead pass 'newline=""' to all open() calls to preserve newlines. And when adding new lines use the first type of newline found in the file.

The test changes make the patching code reuseable and adds a second test with multiple different newlines in the input.

In case we use \n on Windows or \r\n on Linux we don't want
patching those files change every line due to newlines being
adjusted to the platform defaults.

Instead pass 'newline=""' to all open() calls to preserve
newlines. And when adding new lines use the first type of
newline found in the file.

The test changes make the patching code reuseable and adds
a second test with multiple different newlines in the input.
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