fix(tpc): HandlesImports 不再静默 RecursionError + VLogger.warning 补打 exc_info
类别:a(编译器缺陷)+ b(机制漏豁免)—— 类型解析链成环被当成"可忽略异常"吞掉, 上游根因不可见、声明静默退化。 - HandlesImports.py:978 / :1475 / :1583 三处新增 `except RecursionError: raise`, 对齐家族口径(HandlesBase.py:1060-1068:「RecursionError 不是可忽略异常, 是类型解析/声明发射链成环的真缺陷信号」)。成环路径: _TryLoadClassMembersFromPyi ↔ _EmitExternalClassDeclLlvm ↔ _TryLoadStructFromStub (每轮 4 帧),现场与 :2985 深探针记录一致(match.MatchOr.patterns、 stmts.Interactive.body 等"首字段即指针/容器"的类)。 修复前表现为一行 `WARN: HandlesImports: 忽略异常 maximum recursion depth exceeded` + 返回类型退化成 CInt / 形参退化成 i32。 - VLogger.py:warning() 的 exc_info 形参**从未被使用** —— 调用方传了异常却无任何 输出,吞异常点只剩一行 WARN、栈不可见。现与 error() 同口径打印 `Exception: <类型>: <消息>` + traceback(重复帧由 traceback 模块自动折叠为 "[Previous line repeated N more times]",不刷屏)。
This commit is contained in:
1 parent
d3537c7b3f
commit
24573e5af6
2 files changed
+30
No files matched your search
@@ -975,6 +975,15 @@ class ImportHandle(BaseHandle):
|
||||
else:
|
||||
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 RecursionError:
|
||||
# 家族口径(HandlesBase.py:1060-1068):RecursionError 不是"可忽略异常",
|
||||
# 而是类型解析/声明发射链**成环**的真缺陷信号。此前它被本处
|
||||
# `except Exception` 吞成一行 `WARN: 忽略异常 maximum recursion depth exceeded`
|
||||
# + 声明静默退化(现场与 :2985 深探针记录一致:`match.MatchOr.patterns`、
|
||||
# `stmts.Interactive.body` 等"首字段即指针/容器"的类会触发
|
||||
# `_TryLoadClassMembersFromPyi ↔ _EmitExternalClassDeclLlvm ↔ _TryLoadStructFromStub`
|
||||
# 环)。此处 fail-fast 上抛(保留原始栈),暴露上游根因而非掩盖。
|
||||
raise
|
||||
except Exception as e:
|
||||
# NoneType 异常是数据缺失的正常兜底,静默不 WARN(干扰太多)
|
||||
if not (isinstance(e, AttributeError) and "'NoneType'" in str(e)):
|
||||
@@ -1463,6 +1472,10 @@ class ImportHandle(BaseHandle):
|
||||
ReturnTypeInfo = CTypeInfo()
|
||||
ReturnTypeInfo.BaseType = t.CInt()
|
||||
IsPtr = ReturnTypeInfo.IsPtr
|
||||
except RecursionError:
|
||||
# 家族口径(HandlesBase.py:1060-1068):RecursionError 是类型解析链成环的
|
||||
# 真缺陷信号,不允许退化成"默认 CInt"(那会让被指类丢失、下游全部错型)。
|
||||
raise
|
||||
except Exception as e: # 回退:返回类型解析失败时使用默认 CInt
|
||||
# NoneType 异常(如对 None 调 endswith)是数据缺失的正常兜底场景,
|
||||
# 静默不输出 WARN(干扰太多);其他异常保留提示。
|
||||
@@ -1567,6 +1580,10 @@ class ImportHandle(BaseHandle):
|
||||
ParamTypeInfo.ArrayDims = []
|
||||
ParamTypeInfo.PtrCount = max(ParamTypeInfo.PtrCount, 1)
|
||||
ParamType = Gen._ctype_to_llvm(ParamTypeInfo)
|
||||
except RecursionError:
|
||||
# 家族口径(HandlesBase.py:1060-1068):RecursionError 是类型解析链成环的
|
||||
# 真缺陷信号,不允许退化成"默认 i32"(形参错型会让 _adjust_args 行为错乱)。
|
||||
raise
|
||||
except Exception as e: # 回退:参数类型解析失败时使用默认 i32
|
||||
# NoneType 异常是数据缺失的正常兜底,静默不 WARN(干扰太多)
|
||||
if not (isinstance(e, AttributeError) and "'NoneType'" in str(e)):
|
||||
|
||||
@@ -6,6 +6,7 @@ from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import os
|
||||
import traceback
|
||||
from datetime import datetime
|
||||
from typing import Any, Callable, Optional
|
||||
from lib.constants.config import mode as _ConfigMode
|
||||
@@ -167,6 +168,18 @@ class Logger:
|
||||
prefix += f"[{self._colorize(category, Colors.CYAN)}]"
|
||||
|
||||
msg: str = f"{self._colorize('├', Colors.YELLOW)} {prefix}: {message}"
|
||||
if exc_info is not None:
|
||||
# 此前 exc_info 形参**从未被使用**:调用方 `_vlog().warning(..., exc_info=e)`
|
||||
# 传了异常却无任何输出 ⇒ 吞异常点只剩一行 WARN、栈不可见,上游根因无从定位
|
||||
# (如 `HandlesImports: 忽略异常 maximum recursion depth exceeded`)。
|
||||
# 现与 error() 同口径打印异常类型/消息,并附 traceback;重复帧由 traceback
|
||||
# 模块自动折叠为 "[Previous line repeated N more times]",不会刷屏。
|
||||
msg += f"\n{self._colorize('│', Colors.YELLOW)} Exception: {type(exc_info).__name__}: {exc_info}"
|
||||
tb_text: str = traceback.format_exc()
|
||||
# 不在 except 块内调用时 format_exc() 返回 "NoneType: None",此时不附栈
|
||||
if 'NoneType: None' not in tb_text:
|
||||
tb_lines: str = tb_text.rstrip('\n').replace('\n', f"\n{self._colorize('│', Colors.YELLOW)} ")
|
||||
msg += f"\n{self._colorize('│', Colors.YELLOW)} {tb_lines}"
|
||||
self._write(msg, "WARNING")
|
||||
|
||||
def error(self, message: str, category: str = "", exception: Optional[Exception] = None) -> None:
|
||||
|
||||
Reference in new issue
Block a user