Open file in UTF-8 encoding (#6919) (#8943)

FileCallbackHandler cannot handle some language, for example: Chinese. 
Open file using UTF-8 encoding can fix it.
@agola11
  
**Issue**: #6919 
**Dependencies**: NO dependencies,

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
EricFan 2023-08-10 08:54:21 +08:00 committed by GitHub
parent f4a47ec717
commit 618cf5241e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,7 +13,7 @@ class FileCallbackHandler(BaseCallbackHandler):
self, filename: str, mode: str = "a", color: Optional[str] = None
) -> None:
"""Initialize callback handler."""
self.file = cast(TextIO, open(filename, mode))
self.file = cast(TextIO, open(filename, mode, encoding="utf-8"))
self.color = color
def __del__(self) -> None: