From d0e93d70e87ea64f144e8eda7d5d49c27b6158e5 Mon Sep 17 00:00:00 2001 From: Smirking Kitsune <36494751+SmirkingKitsune@users.noreply.github.com> Date: Mon, 2 Sep 2024 13:00:47 -0400 Subject: [PATCH] Fix for create_or_modify_pyi read_text Windows Issue in component_meta.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 Co-authored-by: Abubakar Abid --- .changeset/eighty-jeans-unite.md | 5 +++++ gradio/component_meta.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/eighty-jeans-unite.md diff --git a/.changeset/eighty-jeans-unite.md b/.changeset/eighty-jeans-unite.md new file mode 100644 index 000000000000..9b1be6d8e393 --- /dev/null +++ b/.changeset/eighty-jeans-unite.md @@ -0,0 +1,5 @@ +--- +"gradio": patch +--- + +fix:Fix for create_or_modify_pyi read_text Windows Issue in component_meta.py diff --git a/gradio/component_meta.py b/gradio/component_meta.py index 26787022f942..0593fb197aba 100644 --- a/gradio/component_meta.py +++ b/gradio/component_meta.py @@ -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)