Skip to content

Commit

Permalink
Fix an encoding issue in gradio/components/code.py (#8077)
Browse files Browse the repository at this point in the history
* Fix an enconding issue in gradio/components/code.py

Changes Made:
Modified the postprocess function in gradio/components/code.py to handle file encoding properly.
Added encoding="utf-8" parameter to the open function when reading code files. I hardcoded UTF-8 because I couldn't figure out how to specify the encoding, similar to the fix in #8075. My issue is #8076

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
3210448723 and gradio-pr-bot committed Apr 19, 2024
1 parent 2afca65 commit d7461aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/easy-sites-lie.md
@@ -0,0 +1,5 @@
---
"gradio": patch
---

fix:Fix an encoding issue in gradio/components/code.py
2 changes: 1 addition & 1 deletion gradio/components/code.py
Expand Up @@ -151,7 +151,7 @@ def postprocess(self, value: tuple[str] | str | None) -> None | str:
if value is None:
return None
elif isinstance(value, tuple):
with open(value[0]) as file_data:
with open(value[0], encoding="utf-8") as file_data:
return file_data.read()
else:
return value.strip()
Expand Down

0 comments on commit d7461aa

Please sign in to comment.