v2.5.2: 兼容v2.5.1之前的异常hook代码(v2.5.1会使得旧的GitHub Actions下载脚本报错)

This commit is contained in:
hect0x7 2024-01-17 00:57:05 +08:00 committed by GitHub
parent a2d29994ca
commit 684754af57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -2,7 +2,7 @@
# 被依赖方 <--- 使用方
# config <--- entity <--- toolkit <--- client <--- option <--- downloader
__version__ = '2.5.1'
__version__ = '2.5.2'
from .api import *
from .jm_plugin import *

View File

@ -65,6 +65,13 @@ class ExceptionTool:
CONTEXT_KEY_RE_PATTERN = 'pattern'
CONTEXT_KEY_MISSING_JM_ID = 'missing_jm_id'
# 兼容旧版本
EXTRA_KEY_RESP = 'resp'
EXTRA_KEY_HTML = 'html'
EXTRA_KEY_RE_PATTERN = 'pattern'
EXTRA_KEY_MISSING_JM_ID = 'missing_jm_id'
@classmethod
def raises(cls,
msg: str,
@ -156,3 +163,14 @@ class ExceptionTool:
return
cls.raises(msg)
@classmethod
def replace_old_exception_executor(cls, raises: Callable[[Callable, str, dict], None]):
old = cls.raises
def new(msg, context=None, _etype=None):
if context is None:
context = {}
raises(old, msg, context)
cls.raises = new