diff --git a/lib/Projectrans/Phase2Translator.py b/lib/Projectrans/Phase2Translator.py index 9793648..fc29e3e 100644 --- a/lib/Projectrans/Phase2Translator.py +++ b/lib/Projectrans/Phase2Translator.py @@ -2358,21 +2358,28 @@ class Phase2Translator: # 直接调用它(不依赖 .ctors/.init_array,避免 MinGW 下 .ctors.65534 不执行)。 if self.traceback_enabled: _tb_sha1: str | None = None - for _k, _p in self.sig_files.items(): - try: - if 'traceback' in os.path.basename(_p): - _tb_sha1 = _k - break - if 'Module: traceback' in _ReadTextCached(_p)[:512]: - _tb_sha1 = _k - break - except Exception: - continue + _temp_vpi: str = getattr(self, 'temp_dir', '') or '' + if _temp_vpi and os.path.isdir(_temp_vpi): + for _fn in os.listdir(_temp_vpi): + if not _fn.endswith('.vpi'): + continue + try: + if 'Module: traceback' in _ReadTextCached(os.path.join(_temp_vpi, _fn))[:512]: + _tb_sha1 = _fn[:-4] + break + except Exception: + continue if _tb_sha1 is None: - for _k, _p in getattr(self, '_shared_source_module_sig_files', {}).items(): - if 'traceback' in str(_p): - _tb_sha1 = _k - break + for _k, _p in self.sig_files.items(): + try: + if 'traceback' in os.path.basename(_p): + _tb_sha1 = _k + break + if 'Module: traceback' in _ReadTextCached(_p)[:512]: + _tb_sha1 = _k + break + except Exception: + continue trans.translator.TracebackEnabled = self.traceback_enabled if _tb_sha1 is not None: trans.translator.TracebackInstallSymbol = f'{_tb_sha1}.Install'