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

Fix for create_or_modify_pyi read_text Windows Issue in component_meta.py #9242

Merged
merged 3 commits into from
Sep 2, 2024

Conversation

SmirkingKitsune
Copy link
Contributor

@SmirkingKitsune SmirkingKitsune commented Sep 2, 2024

Sometimes the read_text() call in create_or_modify_pyi will not use expected encoding when reading the source_file.

Description

This will declare the encoding that read_text is supposed to use. It is reading files that are encoded in 'utf-8'. Windows seems to sometimes default to 'CP-1252', but not always. Issue was not present when tested in Unix. I think it is safer to explicitly declare the encoding to be 'utf-8' since the gradio source files that are being read are encoded in 'utf-8'.

Closes: #8316 and Closes: #9241

In some environments the `read_text()` call in `create_or_modify_pyi` will not use expected encoding when reading the `source_file`. In Unix environments (and presumably MacOS though I have not tested), this will default to use the 'utf-8' encoding, which is what the `source_file` are encoded in. In Windows, it seems to default to a different encoding when 'utf-8' should be selected.
@SmirkingKitsune SmirkingKitsune changed the title Fix for create_or_modify_pyi read_text in component_meta.py Fix for create_or_modify_pyi read_text Windows Issue in component_meta.py Sep 2, 2024
@abidlabs
Copy link
Member

abidlabs commented Sep 2, 2024

Makes sense, thanks for the contribution @SmirkingKitsune!

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Sep 2, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website failed! Details
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-pypi-previews.s3.amazonaws.com/ce9cfec38f8f8bb41a7464acad11c02f0ac94da4/gradio-4.42.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@ce9cfec38f8f8bb41a7464acad11c02f0ac94da4#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/ce9cfec38f8f8bb41a7464acad11c02f0ac94da4/gradio-client-1.5.1.tgz

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Sep 2, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
gradio patch
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Fix for create_or_modify_pyi read_text Windows Issue in component_meta.py

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@abidlabs abidlabs enabled auto-merge (squash) September 2, 2024 16:49
@abidlabs abidlabs merged commit d0e93d7 into gradio-app:main Sep 2, 2024
20 checks passed
@SmirkingKitsune SmirkingKitsune deleted the patch-1 branch September 2, 2024 17:36
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.

create_or_modify_pyi Encoding Selection Incorrect in Windows Gradio has a conflict with Python file cp1252
3 participants