@danhachuel/thunderbolt 0.4.88 → 0.4.89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/app/main.py CHANGED
@@ -1,12 +1,20 @@
1
1
  import os
2
2
  import sys
3
+ import io
3
4
 
4
5
  os.environ["PYTHONIOENCODING"] = "utf-8"
5
6
  os.environ["PYTHONUTF8"] = "1"
6
- if hasattr(sys.stdout, "reconfigure"):
7
- sys.stdout.reconfigure(encoding="utf-8", errors="replace")
8
- if hasattr(sys.stderr, "reconfigure"):
9
- sys.stderr.reconfigure(encoding="utf-8", errors="replace")
7
+
8
+ def _force_utf8_stream(stream: object) -> object:
9
+ buffer = getattr(stream, "buffer", None)
10
+ encoding = str(getattr(stream, "encoding", "") or "").lower().replace("-", "_")
11
+ if buffer is not None and encoding != "utf_8":
12
+ return io.TextIOWrapper(buffer, encoding="utf-8", errors="replace", line_buffering=True)
13
+ return stream
14
+
15
+ _original_stdout, _original_stderr = sys.stdout, sys.stderr
16
+ sys.stdout = _force_utf8_stream(sys.stdout)
17
+ sys.stderr = _force_utf8_stream(sys.stderr)
10
18
 
11
19
  import hashlib
12
20
  import json
@@ -1,12 +1,14 @@
1
1
  import os
2
2
  import sys
3
+ import io
3
4
 
4
5
  os.environ["PYTHONIOENCODING"] = "utf-8"
5
6
  os.environ["PYTHONUTF8"] = "1"
6
- if hasattr(sys.stdout, "reconfigure"):
7
- sys.stdout.reconfigure(encoding="utf-8", errors="replace")
8
- if hasattr(sys.stderr, "reconfigure"):
9
- sys.stderr.reconfigure(encoding="utf-8", errors="replace")
7
+ _original_stdout, _original_stderr = sys.stdout, sys.stderr
8
+ if getattr(sys.stdout, "buffer", None) is not None and str(getattr(sys.stdout, "encoding", "") or "").lower().replace("-", "_") != "utf_8":
9
+ sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace", line_buffering=True)
10
+ if getattr(sys.stderr, "buffer", None) is not None and str(getattr(sys.stderr, "encoding", "") or "").lower().replace("-", "_") != "utf_8":
11
+ sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding="utf-8", errors="replace", line_buffering=True)
10
12
 
11
13
  import argparse
12
14
  import time
@@ -1,12 +1,14 @@
1
1
  import os
2
2
  import sys
3
+ import io
3
4
 
4
5
  os.environ["PYTHONIOENCODING"] = "utf-8"
5
6
  os.environ["PYTHONUTF8"] = "1"
6
- if hasattr(sys.stdout, "reconfigure"):
7
- sys.stdout.reconfigure(encoding="utf-8", errors="replace")
8
- if hasattr(sys.stderr, "reconfigure"):
9
- sys.stderr.reconfigure(encoding="utf-8", errors="replace")
7
+ _original_stdout, _original_stderr = sys.stdout, sys.stderr
8
+ if getattr(sys.stdout, "buffer", None) is not None and str(getattr(sys.stdout, "encoding", "") or "").lower().replace("-", "_") != "utf_8":
9
+ sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace", line_buffering=True)
10
+ if getattr(sys.stderr, "buffer", None) is not None and str(getattr(sys.stderr, "encoding", "") or "").lower().replace("-", "_") != "utf_8":
11
+ sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding="utf-8", errors="replace", line_buffering=True)
10
12
 
11
13
  import json
12
14
  import queue
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danhachuel/thunderbolt",
3
- "version": "0.4.88",
3
+ "version": "0.4.89",
4
4
  "description": "Thunderbolt — interface local para operação de canais faceless e motor MoneyPrinterTurbo",
5
5
  "license": "MIT",
6
6
  "main": "scripts/cli.mjs",
package/sitecustomize.py CHANGED
@@ -3,13 +3,22 @@ from __future__ import annotations
3
3
 
4
4
  import os
5
5
  import sys
6
+ import io
6
7
 
7
8
  os.environ["PYTHONIOENCODING"] = "utf-8"
8
9
  os.environ["PYTHONUTF8"] = "1"
9
10
 
10
11
  for stream_name in ("stdin", "stdout", "stderr"):
11
12
  stream = getattr(sys, stream_name, None)
12
- if stream is not None and hasattr(stream, "reconfigure"):
13
+ buffer = getattr(stream, "buffer", None) if stream is not None else None
14
+ encoding = str(getattr(stream, "encoding", "") or "").lower().replace("-", "_") if stream is not None else ""
15
+ if buffer is not None and encoding != "utf_8":
16
+ try:
17
+ replacement = io.TextIOWrapper(buffer, encoding="utf-8", errors="replace", line_buffering=True)
18
+ setattr(sys, stream_name, replacement)
19
+ except (OSError, ValueError):
20
+ pass
21
+ elif stream is not None and hasattr(stream, "reconfigure"):
13
22
  try:
14
23
  stream.reconfigure(encoding="utf-8", errors="replace")
15
24
  except (OSError, ValueError):