Skip to content

Commit

Permalink
Fix for create_or_modify_pyi read_text Windows Issue in component_met…
Browse files Browse the repository at this point in the history
…a.py (#9242)

* Fix for create_or_modify_pyi read_text in component_meta.py

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.

* add changeset

* format

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
  • Loading branch information
3 people committed Sep 2, 2024
1 parent 3817d82 commit d0e93d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/eighty-jeans-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gradio": patch
---

fix:Fix for create_or_modify_pyi read_text Windows Issue in component_meta.py
2 changes: 1 addition & 1 deletion gradio/component_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def create_or_modify_pyi(
):
source_file = Path(inspect.getfile(component_class))

source_code = source_file.read_text()
source_code = source_file.read_text(encoding="utf-8")

current_impl, lineno = extract_class_source_code(source_code, class_name)

Expand Down

0 comments on commit d0e93d7

Please sign in to comment.