[bug] run_pipeline.py subprocess GBK encoding causes stdout=None on Windows #84

Closed
opened 2026-06-03 14:39:29 +08:00 by pzhang_zywl · 2 comments
Owner

问题

运行 python scripts/run_pipeline.py --input input/doc.docx 时,step1_semantic_index.py 子进程在 GBK 环境下 stdout 捕获失败,stderr 线程因 UnicodeDecodeError 崩溃,导致 result.stdout 为 None,pipeline 中断。

根因

scripts/run_pipeline.py:83subprocess.run(capture_output=True, text=True) 未指定 encoding='utf-8'。在 Windows GBK locale 下,子进程输出包含非 GBK 字符时,内部 reader 线程抛出 UnicodeDecodeError: 'gbk' codec can't decode byte,stdout 变为 None。

同样的问题也存在于 run_acceptance_tests() (line 114)。

修复

在 subprocess.run 调用中添加 encoding='utf-8' 参数。代码级修复,UT 可验证。


[da-0603-1426]

## 问题 运行 `python scripts/run_pipeline.py --input input/doc.docx` 时,step1_semantic_index.py 子进程在 GBK 环境下 stdout 捕获失败,stderr 线程因 UnicodeDecodeError 崩溃,导致 result.stdout 为 None,pipeline 中断。 ## 根因 `scripts/run_pipeline.py:83` 的 `subprocess.run(capture_output=True, text=True)` 未指定 `encoding='utf-8'`。在 Windows GBK locale 下,子进程输出包含非 GBK 字符时,内部 reader 线程抛出 `UnicodeDecodeError: 'gbk' codec can't decode byte`,stdout 变为 None。 同样的问题也存在于 `run_acceptance_tests()` (line 114)。 ## 修复 在 subprocess.run 调用中添加 `encoding='utf-8'` 参数。代码级修复,UT 可验证。 --- [da-0603-1426]
pzhang_zywl added the product-code label 2026-06-03 14:39:29 +08:00
Author
Owner

PR 已创建: http://localhost:3000/pzhang_zywl/document_analyzer/pulls/85

变更:

  • run_ir_pipeline() subprocess.run 添加 encoding='utf-8'
  • run_acceptance_tests() subprocess.run 添加 encoding='utf-8' + PYTHONIOENCODING env

等待 CI 通过后 merge。


[da-0603-1426]

PR 已创建: http://localhost:3000/pzhang_zywl/document_analyzer/pulls/85 变更: - `run_ir_pipeline()` subprocess.run 添加 `encoding='utf-8'` - `run_acceptance_tests()` subprocess.run 添加 `encoding='utf-8'` + PYTHONIOENCODING env 等待 CI 通过后 merge。 --- [da-0603-1426]
Author
Owner

问题

run_pipeline.py subprocess.run Windows GBK 编码导致 stdout=None,pipeline 中断。

根因

subprocess.run(capture_output=True, text=True) 未指定 encoding,Windows GBK locale 下内部 reader 线程因非 GBK 字符抛出 UnicodeDecodeError。

修复

在 run_ir_pipeline() 和 run_acceptance_tests() 的 subprocess.run 中添加 encoding='utf-8' + PYTHONIOENCODING env。

验证

  • pytest: 110 passed, 16 skipped
  • merge 后 pipeline 可正常启动

[da-0603-1426]

## 问题 run_pipeline.py subprocess.run Windows GBK 编码导致 stdout=None,pipeline 中断。 ## 根因 subprocess.run(capture_output=True, text=True) 未指定 encoding,Windows GBK locale 下内部 reader 线程因非 GBK 字符抛出 UnicodeDecodeError。 ## 修复 在 run_ir_pipeline() 和 run_acceptance_tests() 的 subprocess.run 中添加 encoding='utf-8' + PYTHONIOENCODING env。 ## 验证 - pytest: 110 passed, 16 skipped - merge 后 pipeline 可正常启动 --- [da-0603-1426]
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: zeekrAI/document_analyzer#84