Skip to content

Conversation

michalChrobot
Copy link
Collaborator

Purpose of this PR

Backport of #3679 aiming to fix windows newline encoding when writing to files from automation

Jira ticket

N/A

Documentation

N/A

Testing & QA (How your changes can be verified during release Playtest)

Tested with main PR that is backported here

Backports

This is a backport of #3679

@michalChrobot michalChrobot self-assigned this Sep 17, 2025
michalChrobot added a commit that referenced this pull request Sep 17, 2025
## Purpose of this PR
This PR follows on
#3677
because even though we don't need to execute release.py when packing the
package (due to existing pvp exception) nor vetting test job (uses
upm-ci which does not run PVP checks) we should future proof release.py
and similar scripts from making this mistake.

The main reason why the release.py was causing the package pack to fail
on windows is that when you open a file in text mode ('w') on Windows,
Python's default behavior is to convert each newline character (\n) into
the platform's standard line separator, which is \r\n (CRLF). This can
cause inconsistencies when the file is used in environments that expect
\n (LF), such as Git.

The solution was to ensure that we are specifying the newline like
`with open(path, 'w', encoding='UTF-8', newline='\n') as file:`

### Jira ticket
N/A

## Documentation
N/A

## Testing & QA (How your changes can be verified during release
Playtest)
PR trigger check was green and I verified that when release.py command
was included in pack job the results were green (see
**[THIS](https://unity-ci.cds.internal.unity3d.com/job/56280166)** job)

## Backports
Backport to `develop` branch in
#3681
@michalChrobot michalChrobot merged commit 1eca4b3 into develop Sep 17, 2025
8 checks passed
@michalChrobot michalChrobot deleted the windows-line-correction-backport branch September 17, 2025 07:51
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