Add encoding to open/writing files on the deploy_discord function (#7054)

* Update client.py

Make open discord_chat.py call encoded to utf-8

* Update client.py

Add another encoding to line 850

* add changeset

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
WilliamHarer 2024-01-18 11:40:59 -08:00 committed by GitHub
parent aaecfe54d9
commit 64c65d8219
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -0,0 +1,6 @@
---
"gradio": patch
"gradio_client": patch
---
feat:Add encoding to open/writing files on the deploy_discord function

View File

@ -841,13 +841,13 @@ class Client:
metadata={"tags": ["gradio-discord-bot"]},
)
with open(str(Path(__file__).parent / "templates" / "discord_chat.py")) as f:
with open(str(Path(__file__).parent / "templates" / "discord_chat.py"),encoding="utf-8") as f:
app = f.read()
app = app.replace("<<app-src>>", self.src)
app = app.replace("<<api-name>>", api_names[0][0])
app = app.replace("<<command-name>>", api_names[0][1])
with tempfile.NamedTemporaryFile(mode="w", delete=False) as app_file:
with tempfile.NamedTemporaryFile(mode="w", delete=False,encoding="utf-8") as app_file:
with tempfile.NamedTemporaryFile(mode="w", delete=False) as requirements:
app_file.write(app)
requirements.write("\n".join(["discord.py==2.3.1"]))