Compare commits

..

2 commits

Author SHA1 Message Date
252cf7d9c0
Merge 8532688bab into 1298e9c398 2025-01-14 14:31:11 +01:00
Alexis Métaireau
8532688bab
FIXUP: remove string tailcut, rename function 2025-01-14 14:31:00 +01:00

View file

@ -20,7 +20,6 @@ from ..util import get_tessdata_dir, replace_control_chars
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
MAX_CONVERSION_LOG_CHARS = 150 * 50 # up to ~150 lines of 50 characters
DOC_TO_PIXELS_LOG_START = "----- DOC TO PIXELS LOG START -----" DOC_TO_PIXELS_LOG_START = "----- DOC TO PIXELS LOG START -----"
DOC_TO_PIXELS_LOG_END = "----- DOC TO PIXELS LOG END -----" DOC_TO_PIXELS_LOG_END = "----- DOC TO PIXELS LOG END -----"
@ -77,7 +76,7 @@ def read_int(f: IO[bytes]) -> int:
return int.from_bytes(untrusted_int, "big", signed=False) return int.from_bytes(untrusted_int, "big", signed=False)
def read_debug_text(text: bytes) -> str: def sanitize_debug_text(text: bytes) -> str:
"""Read all the buffer and return a sanitized version""" """Read all the buffer and return a sanitized version"""
untrusted_text = text.decode("ascii", errors="replace") untrusted_text = text.decode("ascii", errors="replace")
return replace_control_chars(untrusted_text, keep_newlines=True) return replace_control_chars(untrusted_text, keep_newlines=True)
@ -358,7 +357,7 @@ class IsolationProvider(ABC):
stderr_thread.join(timeout=1) stderr_thread.join(timeout=1)
debug_bytes = stderr.getvalue() debug_bytes = stderr.getvalue()
debug_log = read_debug_text(debug_bytes)[:MAX_CONVERSION_LOG_CHARS] debug_log = sanitize_debug_text(debug_bytes)
incomplete = "(incomplete)\n" if stderr_thread.is_alive() else "" incomplete = "(incomplete)\n" if stderr_thread.is_alive() else ""