fix(imports): from . import Y 的 Y 是包内符号(非子模块)时跳过 SHA1 校验
- translate_import_from_module 对 from . import Y 曾无条件把每个 name 拼成 resolved.Y 当子模块校验 SHA1 → json/__parser.vp 的 from . import JsonValue 等符号(json/__init__.vp 定义)被误报"模块 json.JsonValue 未注册 SHA1" - 仅在完整名已注册 SHA1(真子模块)或本地文件时才校验+登记;符号映射 由 translate_import_from_names 的 from-import / re-export 处理 - 顺带:Reexport 懒初始化改用 CompilerFactory.factory.PermPool(配合 TPC 跨模块全局写端修复)
This commit is contained in:
1 parent
a603736f64
commit
c54e87bd6d
1 file changed
+17
-7
@@ -344,9 +344,9 @@ class ImportsGenMixin:
|
||||
return -1
|
||||
# 懒初始化
|
||||
if self.ReexportSha1s is None:
|
||||
self.ReexportSha1s = CompilerFactory.get_perm_pool().alloc(MAX_REEXPORT * 17)
|
||||
self.ReexportFuncs = CompilerFactory.get_perm_pool().alloc(MAX_REEXPORT * 64)
|
||||
self.ReexportSrcs = CompilerFactory.get_perm_pool().alloc(MAX_REEXPORT * 64)
|
||||
self.ReexportSha1s = CompilerFactory.factory.PermPool.alloc(MAX_REEXPORT * 17)
|
||||
self.ReexportFuncs = CompilerFactory.factory.PermPool.alloc(MAX_REEXPORT * 64)
|
||||
self.ReexportSrcs = CompilerFactory.factory.PermPool.alloc(MAX_REEXPORT * 64)
|
||||
if self.ReexportSha1s is None or self.ReexportFuncs is None or self.ReexportSrcs is None:
|
||||
return -1
|
||||
string.memset(self.ReexportSha1s, 0, MAX_REEXPORT * 17)
|
||||
@@ -754,10 +754,20 @@ class ImportsGenMixin:
|
||||
string.strcpy(jb_m, resolved)
|
||||
jb_m[rl_m] = '.'
|
||||
string.strcpy(jb_m + rl_m + 1, alias_m.name)
|
||||
if trans._declare_only == 0:
|
||||
self._check_import_sha1(node, jb_m)
|
||||
trans._imported_modules = self.add_imported_module(
|
||||
trans.Pool, trans._imported_modules, jb_m)
|
||||
# from . import Y 的 Y 不一定是包子模块文件:
|
||||
# 可能是包 __init__.vp 中定义的符号(类/常量,如
|
||||
# json/__init__.vp 的 JsonValue),无独立文件、不注册
|
||||
# SHA1。此前无条件按子模块校验 → 误报"模块 'json.JsonValue'
|
||||
# 未注册 SHA1"。仅当完整名已注册 SHA1(真子模块,如
|
||||
# vpsdk.syscall)或是本地文件时才校验+登记;否则跳过,
|
||||
# 符号映射由 translate_import_from_names 的 from-import
|
||||
# / re-export 处理。
|
||||
if (StubMergerStore.LookupSha1ByModName(jb_m) is not None
|
||||
or self._is_local_module_file(alias_m.name) != 0):
|
||||
if trans._declare_only == 0:
|
||||
self._check_import_sha1(node, jb_m)
|
||||
trans._imported_modules = self.add_imported_module(
|
||||
trans.Pool, trans._imported_modules, jb_m)
|
||||
return 0
|
||||
|
||||
# ============================================================
|
||||
|
||||
Reference in new issue
Block a user