fix: infoharbor_ex.code 存在但不可读时回退占位符,不中断同步#44
Merged
Conversation
SMB 挂载下运行中的通达信会锁定 hq_cache 文件(EPERM), _load_real_names 只兜了文件缺失,read_text 抛 OSError 直接 中断 daily/minutes 同步。现与缺失场景同样降级处理。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 7, 2026
xbfighting
added a commit
that referenced
this pull request
Jul 7, 2026
* feat: 股本/上市日期入库 + 换手率支持 (#45, closes #1) - stock_info 新增 zgb/ltag(万股)、capital_date/list_date, 来自 base.dbf(ZGB/LTAG/GXRQ/SSDATE),缺失/不可读降级 NULL - 换手率(%) = daily_data.volume / stock_info.ltag(手 与 万股 单位差恰好抵消;实测平安 0.547%/茅台 0.328% 与行情软件同量级) - save_stock_info 改单事务快照替换(append 重跑撞 code 唯一约束) - parse_base_dbf 通用化(按列名取值),parse_base_dbf_dy 改为薄封装 - blocks 四链文件读取统一补缺失/不可读降级(#44 同款场景) - 迁移脚本 migrate_stock_info_capital.sql;测试 +4(含目录冒充文件 触发 OSError 的跨平台降级测试) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * docs: 换手率 FAQ/SQL 与股本列说明(README/AGENTS/skill)(#45) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: _try_parse 补捕获 ValueError + 快照替换测试(review 修复) - blocks 链的格式异常(如 base.dbf 缺列)改为单链降级, 不再传播丢弃已收集的其他链结果 - 测试 +2:缺列 DBF 仅地区链降级 / save_stock_info 快照替换与失败回滚 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
#43 引入的
_load_real_names()只处理了名称文件缺失的场景(exists()为假 → 警告 + 占位符回退)。当文件存在但不可读时——实测场景:SMB 挂载会话劣化返回 EPERM;Windows 端通达信运行中锁定 hq_cache 亦同——read_text()抛出的 OSError 无人捕获,直接中断整个 daily/minutes 同步。股票名称是可选增强,daily/minutes 同步仅用
get_stock_list()枚举代码,不依赖名称,不应因此失败。修复
读取包上
try/except OSError,与文件缺失走同一条降级路径:警告日志 + 返回空 dict(get_stock_list回退占位符命名)。测试
test_fallback_placeholder_when_file_unreadable:chmod 000 模拟不可读 → 回退占位符不抛异常(Windows 上 chmod 权限位无效,skipif跳过)pytest tests/test_reader.py10 passed🤖 Generated with Claude Code