Skip to content

Ensure UTF-8 encoding for config.json read/write in config.py#29

Open
mrmeixiang wants to merge 3 commits intoylytdeng:mainfrom
mrmeixiang:main
Open

Ensure UTF-8 encoding for config.json read/write in config.py#29
mrmeixiang wants to merge 3 commits intoylytdeng:mainfrom
mrmeixiang:main

Conversation

@mrmeixiang
Copy link

将 config.py 中 config.json 的读写统一显式指定为 UTF-8 编码,修复 Windows 中文环境下因默认编码差异导致的配置解析异常。

Copy link
Owner

@ylytdeng ylytdeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

评审意见

问题定位准确,修复方向正确,但覆盖范围严重不足。

严重问题

补丁不完整 — 只修了 config.py 3 处,但项目中还有 9+ 处同类问题未修复:

文件 问题
mcp_server.py L31 open(CONFIG_FILE) 未指定 encoding
mcp_server.py L54 open(KEYS_FILE) 未指定 encoding
mcp_server.py L145/174 缓存 JSON 读写未指定 encoding
main.py L31/62 open(keys_file) 未指定 encoding
decrypt_db.py L119 open(KEYS_FILE) 未指定 encoding
monitor.py L152 open(KEYS_FILE) 未指定 encoding
monitor_web.py L1886 open(KEYS_FILE) 未指定 encoding

这些文件在 Windows GBK 环境下同样会报 UnicodeDecodeError

建议

  1. 扩大修改范围,一次性修完所有 open() 调用
  2. 或者提取通用工具函数 load_json_file(path) / save_json_file(path, data),集中处理编码
  3. 如果想分步提交,可以先合并此 PR,但必须立即跟进覆盖其余文件的 PR

Copy link
Author

@mrmeixiang mrmeixiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已按照建议完成全量修改,我本地的项目成功运行(^-^)V
@ylytdeng Fixes #29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants