diff --git a/lib/core/Handles/HandlesImports.py b/lib/core/Handles/HandlesImports.py index b341a0a..57bf388 100644 --- a/lib/core/Handles/HandlesImports.py +++ b/lib/core/Handles/HandlesImports.py @@ -777,10 +777,12 @@ class ImportHandle(BaseHandle): self._LoadModuleDeclarationsFromFile(sha1_pyi, Gen, module_name=alias.name, register_module_name=register_module_name, reexport_package=module_name) has_functions_or_classes = True except Exception as e: - if module_name == 'pyzlib': - node_type = type(node).__name__ - name = getattr(node, 'name', getattr(node, 'attr', '?')) - _vlog().warning(f"HandlesImports: 忽略异常 {e}", exc_info=e) + # NoneType 异常是数据缺失的正常兜底,静默不 WARN(干扰太多) + if not (isinstance(e, AttributeError) and "'NoneType'" in str(e)): + if module_name == 'pyzlib': + node_type = type(node).__name__ + name = getattr(node, 'name', getattr(node, 'attr', '?')) + _vlog().warning(f"HandlesImports: 忽略异常 {e}", exc_info=e) continue if not has_functions_or_classes and module_name: self._LoadDeclarationsFromStubLlvm(module_name, Gen) @@ -1163,7 +1165,10 @@ class ImportHandle(BaseHandle): ReturnTypeInfo.BaseType = t.CInt() IsPtr = ReturnTypeInfo.IsPtr except Exception as e: # 回退:返回类型解析失败时使用默认 CInt - _vlog().warning(f"HandlesImports: 忽略异常 {e}", exc_info=e) + # NoneType 异常(如对 None 调 endswith)是数据缺失的正常兜底场景, + # 静默不输出 WARN(干扰太多);其他异常保留提示。 + if not (isinstance(e, AttributeError) and "'NoneType'" in str(e)): + _vlog().warning(f"HandlesImports: 忽略异常 {e}", exc_info=e) ReturnTypeInfo = CTypeInfo() ReturnTypeInfo.BaseType = t.CInt() else: @@ -1261,7 +1266,9 @@ class ImportHandle(BaseHandle): ParamTypeInfo.PtrCount = max(ParamTypeInfo.PtrCount, 1) ParamType = Gen._ctype_to_llvm(ParamTypeInfo) except Exception as e: # 回退:参数类型解析失败时使用默认 i32 - _vlog().warning(f"HandlesImports: 忽略异常 {e}", exc_info=e) + # NoneType 异常是数据缺失的正常兜底,静默不 WARN(干扰太多) + if not (isinstance(e, AttributeError) and "'NoneType'" in str(e)): + _vlog().warning(f"HandlesImports: 忽略异常 {e}", exc_info=e) ParamType = ir.IntType(32) if isinstance(ParamType, ir.VoidType) or (isinstance(ParamType, ir.PointerType) and isinstance(ParamType.pointee, ir.VoidType)): AnnName = None @@ -2109,7 +2116,7 @@ class ImportHandle(BaseHandle): if len(parts[0]) == 16 and all(c in '0123456789abcdef' for c in parts[0]): actual_sha1 = parts[0] - is_packed = struct_body.startswith('<{') and struct_body.endswith('}>') + is_packed = struct_body is not None and struct_body.startswith('<{') and struct_body.endswith('}>') if struct_body and struct_body != 'opaque': elem_types = [] if is_packed: @@ -2461,7 +2468,7 @@ class ImportHandle(BaseHandle): struct_body = struct_def_match.group(3).strip() if struct_body and struct_body != 'opaque': elem_types = [] - is_packed = struct_body.startswith('<{') and struct_body.endswith('}>') + is_packed = struct_body is not None and struct_body.startswith('<{') and struct_body.endswith('}>') if is_packed: inner = struct_body[2:-1].strip() else: