💫 Toolkit to help you get started with SDD or any other process!
fix(cli): force UTF-8 stdout/stderr on Windows to prevent UnicodeEncodeError (#2817)
Rafael Figuereo9e05195d246f
diff --git a/src/specify_cli/__init__.py b/src/specify_cli/__init__.pyindex d1f71e7e0..684dc5b57 100644--- a/src/specify_cli/__init__.py+++ b/src/specify_cli/__init__.py@@ -3323,6 +3323,17 @@ def workflow_catalog_remove(def main():+ # On Windows the default stdout/stderr code page (e.g. cp1252) cannot encode+ # the Rich banner and box-drawing glyphs, so the CLI crashes with+ # UnicodeEncodeError whenever output is not a UTF-8 TTY (piped, redirected to+ # a file, or running under a legacy code page). Force UTF-8 with graceful+ # replacement so output degrades instead of aborting. No-op on POSIX.+ if sys.platform == "win32":+ for _stream in (sys.stdout, sys.stderr):+ try:+ _stream.reconfigure(encoding="utf-8", errors="replace")+ except (AttributeError, ValueError, OSError):+ passapp()if __name__ == "__main__":