gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
32.41k stars 2.42k forks source link

Fix encoding error in gradio/routes.py #8435

Closed Col0ring closed 3 months ago

Col0ring commented 3 months ago

Description

gradio/routes.py

  if key not in app.custom_component_hashes:
      app.custom_component_hashes[key] = hashlib.md5(
          Path(path).read_text().encode()
      ).hexdigest()

Change Path(path).read_text().encode() to Path(path).read_text(encoding="utf-8").encode() to support custom components with i18n code.

Closes: #8426

🎯 PRs Should Target Issues

Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.

Not adhering to this guideline will result in the PR being closed.

Tests

  1. PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests: bash scripts/run_all_tests.sh

  2. You may need to run the linters: bash scripts/format_backend.sh and bash scripts/format_frontend.sh

gradio-pr-bot commented 3 months ago

🪼 branch checks and previews

• Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
:unicorn: Changes failed! Workflow log

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/fcc4396235236fcae945b90a2a746a88db795884/gradio-4.32.2-py3-none-any.whl

Install Gradio Python Client from this PR

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

Install Gradio JS Client from this PR

npm install https://gradio-builds.s3.amazonaws.com/fcc4396235236fcae945b90a2a746a88db795884/gradio-client-0.20.1.tgz