Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Conversation

@ahirreddy
Copy link
Collaborator

Python auto-detects the default string encoding based on several environment variables:

LANG=C.UTF-8
LC_CTYPE=en_US.UTF-8

These are set by default in shells Devbox, and thus the encoding used by default is UTF-8. However, when invoking the git-shim from a shell where these variables are not set or as a subprocess (like from the test-shard CLI) - the default encoding is ASCII. This results in the following error whenever UTF-8 is present in the output of any command (usually a diff)

UnicodeEncodeError: 'ascii' codec can't encode characters in position <x>-<y>: ordinal not in range(128)

This PR fixes the issue by explicitly setting the encoding of the printed output to UTF-8 - so we don't need to rely on it being properly set in the environment or by callers.

Python auto-detects the default string encoding based on several environment variables:
```
LANG=C.UTF-8
LC_CTYPE=en_US.UTF-8
```
These are set by default in shells Devbox, and thus the encoding used by default is UTF-8. However, when invoking the git-shim from a shell where these variables are not set or as a subprocess (like from the test-shard CLI) - the default encoding is ASCII. This results in the following error whenever UTF-8 is present in the output of any command (usually a diff)

```
UnicodeEncodeError: 'ascii' codec can't encode characters in position <x>-<y>: ordinal not in range(128)
```

This PR fixes the issue by explicitly setting the encoding of the printed output to UTF-8 - so we don't need to rely on it being properly set in the environment or by callers.
@ahirreddy ahirreddy changed the title Handle UTF-8 output in all environments Git Proxy - Handle UTF-8 output in all environments Feb 10, 2021
@gabrielrussoc
Copy link
Contributor

how urgent is this? can we merge this after we move devbox to universe?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants