Spaces:
Runtime error
Runtime error
Commit ·
78f1567
1
Parent(s): 37efa75
fix
Browse files- sitecustomize.py +21 -0
sitecustomize.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Project-wide UTF-8 console setup for Windows deployments."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import sys
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def _reconfigure_stream(stream_name: str) -> None:
|
| 9 |
+
stream = getattr(sys, stream_name, None)
|
| 10 |
+
if stream is None:
|
| 11 |
+
return
|
| 12 |
+
reconfigure = getattr(stream, "reconfigure", None)
|
| 13 |
+
if callable(reconfigure):
|
| 14 |
+
try:
|
| 15 |
+
reconfigure(encoding="utf-8", errors="replace")
|
| 16 |
+
except Exception:
|
| 17 |
+
pass
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
_reconfigure_stream("stdout")
|
| 21 |
+
_reconfigure_stream("stderr")
|