Xinops 1.2.2__tar.gz → 1.2.3__tar.gz
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.
- {xinops-1.2.2 → xinops-1.2.3}/PKG-INFO +1 -1
- {xinops-1.2.2 → xinops-1.2.3}/xinops/__init__.py +1 -1
- {xinops-1.2.2 → xinops-1.2.3}/xinops/_core.py +11 -5
- {xinops-1.2.2 → xinops-1.2.3}/xinops.egg-info/PKG-INFO +1 -1
- {xinops-1.2.2 → xinops-1.2.3}/README.md +0 -0
- {xinops-1.2.2 → xinops-1.2.3}/pyproject.toml +0 -0
- {xinops-1.2.2 → xinops-1.2.3}/setup.cfg +0 -0
- {xinops-1.2.2 → xinops-1.2.3}/setup.py +0 -0
- {xinops-1.2.2 → xinops-1.2.3}/xinops/_email.py +0 -0
- {xinops-1.2.2 → xinops-1.2.3}/xinops/_excel.py +0 -0
- {xinops-1.2.2 → xinops-1.2.3}/xinops/_export.py +0 -0
- {xinops-1.2.2 → xinops-1.2.3}/xinops/_feishu.py +0 -0
- {xinops-1.2.2 → xinops-1.2.3}/xinops/_hive.py +0 -0
- {xinops-1.2.2 → xinops-1.2.3}/xinops/_misc.py +0 -0
- {xinops-1.2.2 → xinops-1.2.3}/xinops/_wecom.py +0 -0
- {xinops-1.2.2 → xinops-1.2.3}/xinops.egg-info/SOURCES.txt +0 -0
- {xinops-1.2.2 → xinops-1.2.3}/xinops.egg-info/dependency_links.txt +0 -0
- {xinops-1.2.2 → xinops-1.2.3}/xinops.egg-info/requires.txt +0 -0
- {xinops-1.2.2 → xinops-1.2.3}/xinops.egg-info/top_level.txt +0 -0
|
@@ -15,11 +15,14 @@ SECRETS_FILE_NAMES = ("xinops_secrets.yaml", "pypi_ku_secrets.yaml")
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
def _make_stdout_gbk_safe():
|
|
18
|
-
"""让控制台输出在 GBK
|
|
18
|
+
"""让控制台输出在 GBK 终端永不崩溃 + 强制行缓冲立即上屏。
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
背景1:任务计划/双击运行的 cmd 是 GBK(cp936),print emoji(等)会抛
|
|
21
21
|
UnicodeEncodeError 中断任务。本函数在包导入时把 stdout/stderr 包装为
|
|
22
22
|
errors='replace':不可编码字符显示为 ?(功能无损),UTF-8 终端完全不受影响。
|
|
23
|
+
背景2:PyCharm 运行台等非 tty 环境默认块缓冲(攒约8KB才上屏),表现为
|
|
24
|
+
"程序快结束才一次性打印全部日志"。此处统一设 line_buffering=True:
|
|
25
|
+
每遇换行立即刷新,所有 print(含业务脚本自己的)实时可见。
|
|
23
26
|
(对已重配置过的解释器幂等)
|
|
24
27
|
"""
|
|
25
28
|
for name in ("stdout", "stderr"):
|
|
@@ -27,11 +30,14 @@ def _make_stdout_gbk_safe():
|
|
|
27
30
|
if stream is None or not hasattr(stream, "buffer"):
|
|
28
31
|
continue
|
|
29
32
|
enc = getattr(stream, "encoding", "") or "utf-8"
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
# 幂等:errors 已是 replace 且已是行缓冲才跳过
|
|
34
|
+
# (注意 -X utf8 解释器默认 errors=replace 但 line_buffering=False,不能只看 errors)
|
|
35
|
+
if "replace" in (getattr(stream, "errors", "") or "") and \
|
|
36
|
+
getattr(stream, "line_buffering", False):
|
|
37
|
+
continue
|
|
32
38
|
try:
|
|
33
39
|
new_stream = io.TextIOWrapper(stream.buffer, encoding=enc, errors="replace",
|
|
34
|
-
line_buffering=
|
|
40
|
+
line_buffering=True)
|
|
35
41
|
setattr(sys, name, new_stream)
|
|
36
42
|
except Exception:
|
|
37
43
|
pass # 包装失败则保持原样(极端环境,不因初始化崩掉导入)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|