You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the opened issues and there are no duplicates
Describe the bug
I encountered a bug when running a Flet application that contains accented characters (Portuguese language) in the manifest.json file. The application throws a UnicodeDecodeError when trying to read the manifest file.
Environment:
Python: 3.12.7
Flet: 0.25.2
Operating System: Windows
Dependencies:
flet==0.25.2
flet-cli==0.25.2
flet-desktop==0.25.2
flet-web==0.25.2
uvicorn==0.34.0
websockets==14.1
The error occurs in:
File "...flet_web\patch_index.py", line 93, in patch_manifest_json
manifest = json.loads(f.read())
Workaround:
Removing accented characters from the manifest.json file resolves the issue:
{
"name": "Gestao de Estoque e Financeira",
"short_name": "ESTOQUE RAPIDO",
"start_url": ".",
"display": "standalone",
"background_color": "#000000",
"theme_color": "#000000",
"description": "Projeto desenvolvido pela Sistrom Sistemas Web!",
"orientation": "natural"
}
Code sample
Code
importfletasftfromsrc.pages.homeimporthomefromsrc.pages.landing_pageimportlanding_pagefromsrc.pages.loginimportlogindefmain(page: ft.Page):
# Força a limpeza do cache no início da aplicaçãopage.clean()
ifnothasattr(page, 'sessions_data'):
page.sessions_data= {}
page.title="EstoqueRápido"page.theme_mode=ft.ThemeMode.LIGHTpage.vertical_alignment=ft.MainAxisAlignment.CENTERpage.window.min_width=300page.padding=0page.spacing=0# Rotasdefroute_change(e: ft.RouteChangeEvent):
page.views.clear()
pg_view=Nonematche.route:
case'/': # Raiz: Landing Pagepg_view=ft.View(
route='/',
controls=[landing_page(page)],
appbar=page.appbar,
vertical_alignment=ft.MainAxisAlignment.CENTER,
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
)
case'signup': # Registropg_view=ft.View(
route='/signup',
# controls=[signup(page)],vertical_alignment=ft.MainAxisAlignment.CENTER,
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
)
case'login':
pg_view=ft.View(
route='/login',
controls=[login(page)],
vertical_alignment=ft.MainAxisAlignment.CENTER,
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
)
case'logout':
# page.sessions_data.clear()page.route='/'case'home': # Homepage do usuário logadopg_view=ft.View(
route='/home',
controls=[home(page)],
vertical_alignment=ft.MainAxisAlignment.CENTER,
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
)
case _:
# Opcional: tratamento para rotas não encontradaspg_view=ft.View(
route="/404",
controls=[
ft.AppBar(
title=ft.Text("Página não encontrada"),
bgcolor=ft.Colors.SURFACE_VARIANT
),
ft.Text("404 - Página não encontrada", size=30),
ft.ElevatedButton(
text="Voltar para Início",
on_click=lambda_: page.go("/")
)
],
vertical_alignment=ft.MainAxisAlignment.CENTER,
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
)
page.views.append(pg_view)
page.update()
defview_pop(e: ft.ViewPopEvent):
page.views.pop()
top_view=page.views[-1]
page.go(top_view.route)
page.on_route_change=route_changepage.on_view_pop=view_poppage.go(page.route)
if__name__=='__main__':
ft.app(target=main, assets_dir="assets", view=ft.WEB_BROWSER)
To reproduce
Create a manifest.json file with accented characters
Run the application using flet run main.py -w
Original manifest.json (causes error):
{
"name": "Gestão de Estoque e Financeira",
"short_name": "ESTOQUE RÁPIDO",
"start_url": ".",
"display": "standalone",
"background_color": "#000000",
"theme_color": "#000000",
"description": "Projeto desenvolvido pela Sistrom Sistemas Web!",
"orientation": "natural"
}
### Expected behaviorThe application should be able to handle UTF-8 encoded characters in the manifest.json file, especially considering that Flet is used internationally and many languages use accented characters.Impact:This bug affects applications that use non-ASCII characters in their manifest.json file, which is particularly important for internationalization and localization purposes.### Screenshots / Videos<details open><summary>Captures</summary>
[Upload media here]
</details>### Operating SystemWindows### Operating system detailsWindows 11 Pro### Flet version0.25.2### RegressionI'm not sure / I don't know### Suggestions_No response_### Logs<details open><summary>Logs</summary>```console(venv) PS D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido> flet run main.py -w --verboseD:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\websockets\legacy\__init__.py:6: DeprecationWarning: websockets.legacy is deprecated; see https://websockets.readthedocs.io/en/stable/howto/upgrade.html for upgrade instructionswarnings.warn( # deprecated in 14.0 - 2024-11-09D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\uvicorn\protocols\websockets\websockets_impl.py:17: DeprecationWarning: websockets.server.WebSocketServerProtocol is deprecatedfrom websockets.server import WebSocketServerProtocolhttp://127.0.0.1:51747ERROR: Exception in ASGI applicationTraceback (most recent call last):File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\uvicorn\protocols\http\httptools_impl.py", line 409, in run_asgiresult = await app( # type: ignore[func-returns-value]^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\uvicorn\middleware\proxy_headers.py", line 60, in __call__return await self.app(scope, receive, send)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\fastapi\applications.py", line 1054, in __call__await super().__call__(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\applications.py", line 113, in __call__await self.middleware_stack(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\middleware\errors.py", line 187, in __call__raise excFile "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\middleware\errors.py", line 165, in __call__await self.app(scope, receive, _send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\middleware\exceptions.py", line 62, in __call__await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_appraise excFile "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_appawait app(scope, receive, sender)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\routing.py", line 715, in __call__await self.middleware_stack(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\routing.py", line 735, in appawait route.handle(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\routing.py", line 460, in handleawait self.app(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\fastapi\applications.py", line 1054, in __call__await super().__call__(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\applications.py", line 113, in __call__await self.middleware_stack(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\middleware\errors.py", line 187, in __call__raise excFile "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\middleware\errors.py", line 165, in __call__await self.app(scope, receive, _send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\middleware\exceptions.py", line 62, in __call__await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_appraise excFile "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_appawait app(scope, receive, sender)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\routing.py", line 715, in __call__await self.middleware_stack(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\routing.py", line 735, in appawait route.handle(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\routing.py", line 460, in handleawait self.app(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\flet_web\fastapi\flet_static_files.py", line 78, in __call__await self.__once.do(self.__config, scope["root_path"])File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\flet\utils\once.py", line 13, in doawait func(*args, **kwargs)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\flet_web\fastapi\flet_static_files.py", line 173, in __configpatch_manifest_json(File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\flet_web\patch_index.py", line 93, in patch_manifest_jsonmanifest = json.loads(f.read())^^^^^^^^File "C:\Users\nilto\AppData\Local\Programs\Python\Python312\Lib\encodings\cp1252.py", line 23, in decodereturn codecs.charmap_decode(input,self.errors,decoding_table)[0]^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 78: character maps to <undefined>ERROR: Exception in ASGI applicationTraceback (most recent call last):File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\uvicorn\protocols\http\httptools_impl.py", line 409, in run_asgiresult = await app( # type: ignore[func-returns-value]^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\uvicorn\middleware\proxy_headers.py", line 60, in __call__return await self.app(scope, receive, send)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\fastapi\applications.py", line 1054, in __call__await super().__call__(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\applications.py", line 113, in __call__await self.middleware_stack(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\middleware\errors.py", line 187, in __call__raise excFile "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\middleware\errors.py", line 165, in __call__await self.app(scope, receive, _send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\middleware\exceptions.py", line 62, in __call__await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_appraise excFile "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_appawait app(scope, receive, sender)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\routing.py", line 715, in __call__await self.middleware_stack(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\routing.py", line 735, in appawait route.handle(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\routing.py", line 460, in handleawait self.app(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\fastapi\applications.py", line 1054, in __call__await super().__call__(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\applications.py", line 113, in __call__await self.middleware_stack(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\middleware\errors.py", line 187, in __call__raise excFile "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\middleware\errors.py", line 165, in __call__await self.app(scope, receive, _send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\middleware\exceptions.py", line 62, in __call__await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_appraise excFile "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_appawait app(scope, receive, sender)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\routing.py", line 715, in __call__await self.middleware_stack(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\routing.py", line 735, in appawait route.handle(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\starlette\routing.py", line 460, in handleawait self.app(scope, receive, send)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\flet_web\fastapi\flet_static_files.py", line 78, in __call__await self.__once.do(self.__config, scope["root_path"])File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\flet\utils\once.py", line 13, in doawait func(*args, **kwargs)File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\flet_web\fastapi\flet_static_files.py", line 173, in __configpatch_manifest_json(File "D:\AppData\OneDrive\Desenvolvimento\Projetos\python\estoquerapido\venv\Lib\site-packages\flet_web\patch_index.py", line 93, in patch_manifest_jsonmanifest = json.loads(f.read())^^^^^^^^File "C:\Users\nilto\AppData\Local\Programs\Python\Python312\Lib\encodings\cp1252.py", line 23, in decodereturn codecs.charmap_decode(input,self.errors,decoding_table)[0]^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 78: character maps to <undefined>
Additional details
No response
The text was updated successfully, but these errors were encountered:
Duplicate Check
Describe the bug
I encountered a bug when running a Flet application that contains accented characters (Portuguese language) in the manifest.json file. The application throws a UnicodeDecodeError when trying to read the manifest file.
Environment:
The error occurs in:
Workaround:
Removing accented characters from the manifest.json file resolves the issue:
Code sample
Code
To reproduce
flet run main.py -w
Original manifest.json (causes error):
Additional details
No response
The text was updated successfully, but these errors were encountered: