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

add utf8 encoding when opening files for windows #1484

Merged
merged 3 commits into from
May 24, 2023
Merged

add utf8 encoding when opening files for windows #1484

merged 3 commits into from
May 24, 2023

Conversation

abidlabs
Copy link
Member

The metadata_save() method in repocard.py does not work on Windows when creating Spaces. The reason is that UTF-8 encoding is not assumed on Windows and the presence of emojis in Spaces README leads to a UnicodeEncodeError. The simple fix is to set the encoding="utf8" when reading and writing the file, as is done in this PR.

More info about this issue: https://discuss.python.org/t/pep-597-use-utf-8-for-default-text-file-encoding/1819

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented May 24, 2023

The documentation is not available anymore as the PR was closed or merged.

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix and the test @abidlabs ! I fixed the test on Windows but overall looks good :)

@Wauplin Wauplin merged commit 1c03f0e into main May 24, 2023
@Wauplin Wauplin deleted the utf8-windows branch May 24, 2023 08:41
Copy link
Member

@julien-c julien-c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

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.

4 participants