0
Fork 0
mirror of https://github.com/Silent1566/webhtv.git synced 2026-10-18 07:09:16 +00:00

fix(py): 缺失 getDependence 的 py 站源不再被静默降级为空

getDependence 是 WebHTV 桥的私有扩展,不是 TVBox/猫源 py 契约的一部分。
Spider.init() 无条件通过 app.getDependence 调用它,而默认实现只存在于
内置 base/spider.py,因此不继承该基类的单文件 py 源(如用户导入的
badnews_spider.py)会抛 AttributeError;PyLoader 捕获后返回全空的
SpiderNull 并永久缓存,首页/分类/搜索全部空白且不留任何可诊断线索。

- app.py: getDependence 用 getattr 兜底,缺失即视为无依赖;用 getattr
  而非 try/except AttributeError,保证真实 getDependence 的内部异常仍会
  正常抛出而不被吞掉
- PyLoader: 初始化失败改走 SpiderDebug(python-spider tag),带上 key/api
  与异常类型,替代原先不进诊断日志的 printStackTrace
- 新增 chaquo/src/test/python/test_app_bridge_contract.py 固化上述契约

Verification: chaquo/src/test/python 契约测试 14 tests 全通过(新增 test_app_bridge_contract.py 7 项 + 既有 test_webhtv_logging.py 7 项,OK,0.005s);红证:把 app.py 的 getDependence 还原为修复前 ru.getDependence() 后同一测试集 1 failure + 2 errors,复现 AttributeError: 'SpiderWithoutGetDependence' object has no attribute 'getDependence';:chaquo:compileArm64_v8aDebugJavaWithJavac 与 :app:compileMobileArm64_v8aDebugJavaWithJavac 通过(BUILD SUCCESSFUL in 31s);app.py py_compile 通过且行尾保持 CRLF(133 CRLF / 0 bare LF)

Task-Guard: PY-GETDEPENDENCE-COMPAT-20261016
This commit is contained in:
Silent1566 2026-10-16 09:47:41 +08:00
commit 317fa9021d
3 changed files with 130 additions and 3 deletions