mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-25 22:00:19 +08:00
Fix custom nodes printing unicode in logs on Windows
This commit is contained in:
parent
4f6615e939
commit
09e4f2d1c4
@ -16,7 +16,8 @@ class LogInterceptor(io.TextIOWrapper):
|
|||||||
def __init__(self, stream, *args, **kwargs):
|
def __init__(self, stream, *args, **kwargs):
|
||||||
buffer = stream.buffer
|
buffer = stream.buffer
|
||||||
encoding = stream.encoding
|
encoding = stream.encoding
|
||||||
super().__init__(buffer, *args, **kwargs, encoding=encoding, line_buffering=stream.line_buffering)
|
# Use 'replace' error handling to avoid Unicode encoding errors on Windows
|
||||||
|
super().__init__(buffer, *args, **kwargs, encoding=encoding, errors='replace', line_buffering=stream.line_buffering)
|
||||||
self._lock = threading.Lock()
|
self._lock = threading.Lock()
|
||||||
self._flush_callbacks = []
|
self._flush_callbacks = []
|
||||||
self._logs_since_flush = []
|
self._logs_since_flush = []
|
||||||
@ -32,7 +33,11 @@ class LogInterceptor(io.TextIOWrapper):
|
|||||||
logs.pop()
|
logs.pop()
|
||||||
logs.append(entry)
|
logs.append(entry)
|
||||||
if not self.closed:
|
if not self.closed:
|
||||||
super().write(data)
|
try:
|
||||||
|
super().write(data)
|
||||||
|
except UnicodeEncodeError:
|
||||||
|
# some random bs in custom nodes will trigger errors on Windows
|
||||||
|
super().write(data.encode(self.encoding, errors='replace').decode(self.encoding))
|
||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
if not self.closed:
|
if not self.closed:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user