From 56153eeb971dbf58ecf598553c5a9afd9e954227 Mon Sep 17 00:00:00 2001 From: Justin Gu <97915@qq.com> Date: Sat, 4 Jul 2026 02:11:27 +0800 Subject: [PATCH] =?UTF-8?q?release:=20v1.17.7=20=E2=80=94=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=20Windows=20CI=20fixture=20=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E7=BC=96=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.17.5 引入的 tests/fixtures/ex_history_transaction.json 含中文注释,Windows CI 默认用 cp1252 解码 UTF-8 文件触发 UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f,导致 3 个 Windows 矩阵的 test_parse_ex_history_transaction_hk 失败(Linux 矩阵因默认 utf-8 不受影响)。 修复:所有 fixture 读取显式指定 encoding='utf-8': - test_hk_transaction.py 的 load_hex/load_json(直接触发点) - test_commands_offline.py 的 load_hex(纯 ASCII hex,当前未触发但一并统一) - test_decode_errors.py 的 _load_hex(同上) 867 单测全绿,ruff format/check / mypy strict 通过。 --- CHANGELOG.md | 8 ++++++++ pyproject.toml | 2 +- tests/unit/test_commands_offline.py | 2 +- tests/unit/test_decode_errors.py | 2 +- tests/unit/test_hk_transaction.py | 4 ++-- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7372433..8f517c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ 本文件记录 easy-tdx 的版本变更。格式遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/)。 +## [1.17.7] — 2026-07-04 + +**修复 Windows CI:fixture 文件读取编码** —— 1.17.5 引入的 `tests/fixtures/ex_history_transaction.json` 含中文注释,Windows CI 默认用 cp1252 解码 UTF-8 文件触发 `UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f`,导致 3 个 Windows 矩阵(3.10/3.12/3.13)的 `test_parse_ex_history_transaction_hk` 失败。统一为 fixture 读取显式指定 `encoding="utf-8"`。**867 单测全绿**,ruff format/check / mypy strict 通过,Windows + Linux 矩阵均转绿。 + +### 修复 + +- **Windows fixture 读取编码**(`tests/unit/test_hk_transaction.py` `load_hex`/`load_json`、`tests/unit/test_commands_offline.py` `load_hex`、`tests/unit/test_decode_errors.py` `_load_hex`)—— 所有 fixture 文件读取显式指定 `encoding="utf-8"`,避免 Windows 默认 cp1252 编码读取含中文 fixture 时 `UnicodeDecodeError`。`test_commands_offline` 与 `test_decode_errors` 的 hex 文件虽为纯 ASCII 当前未触发,但一并修复以统一编码规范、防范未来回归。 + ## [1.17.6] — 2026-07-04 **港股逐笔成交:补充 start 倒序语义文档 + 新增 goods_transaction_all 全量取数** —— 回应 issue #14 后用户反馈:默认 `count=2000` 取回的成交记录时间全集中在尾盘(如 02715 全天成交 13327 笔,count=2000 只取到最近 2000 笔)。根因是通达信逐笔协议(A 股 0x122F 与港股 ex 0x23FC/0x2406 一致)的 `start` 为**倒序**语义——start=0 指向最新一笔(收盘方向),并非 bug。本次:补 docstring 说明 start 语义;新增 `goods_transaction_all` 自动翻页取全天全部成交。**867 单测全绿**(+5),ruff format/check / mypy strict 通过。 diff --git a/pyproject.toml b/pyproject.toml index 5ecff2d..448df95 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "easy-tdx" -version = "1.17.6" +version = "1.17.7" description = "通达信 TCP 协议行情数据客户端,支持在线行情、离线数据读取与写入同步" readme = "README.md" requires-python = ">=3.10" diff --git a/tests/unit/test_commands_offline.py b/tests/unit/test_commands_offline.py index e8b8213..e33fd9a 100644 --- a/tests/unit/test_commands_offline.py +++ b/tests/unit/test_commands_offline.py @@ -14,7 +14,7 @@ FIXTURES = pathlib.Path(__file__).parent.parent / "fixtures" def load_hex(name: str) -> bytes: - return bytes.fromhex((FIXTURES / f"{name}.hex").read_text().strip()) + return bytes.fromhex((FIXTURES / f"{name}.hex").read_text(encoding="utf-8").strip()) # --------------------------------------------------------------------------- diff --git a/tests/unit/test_decode_errors.py b/tests/unit/test_decode_errors.py index 9f5d353..1770752 100644 --- a/tests/unit/test_decode_errors.py +++ b/tests/unit/test_decode_errors.py @@ -17,7 +17,7 @@ FIXTURES = Path(__file__).parent.parent / "fixtures" def _load_hex(name: str) -> bytes: - return bytes.fromhex((FIXTURES / f"{name}.hex").read_text().strip()) + return bytes.fromhex((FIXTURES / f"{name}.hex").read_text(encoding="utf-8").strip()) def test_security_count_truncated_raises_tdxdecodeerror() -> None: diff --git a/tests/unit/test_hk_transaction.py b/tests/unit/test_hk_transaction.py index 4448547..4aaf38d 100644 --- a/tests/unit/test_hk_transaction.py +++ b/tests/unit/test_hk_transaction.py @@ -40,11 +40,11 @@ FIXTURES = pathlib.Path(__file__).parent.parent / "fixtures" def load_hex(name: str) -> bytes: - return bytes.fromhex((FIXTURES / f"{name}.hex").read_text().strip()) + return bytes.fromhex((FIXTURES / f"{name}.hex").read_text(encoding="utf-8").strip()) def load_json(name: str) -> dict: - return json.loads((FIXTURES / f"{name}.json").read_text()) + return json.loads((FIXTURES / f"{name}.json").read_text(encoding="utf-8")) # ---------------------------------------------------------------------------