1
0

daemon error-handling: fix traceback.format_exception() on old python

The new API for traceback.format_exception was only added in python 3.10 (91e93794d5).
This commit is contained in:
SomberNight
2024-06-05 14:45:28 +00:00
parent 444b3f3e17
commit 0866581b2c
3 changed files with 13 additions and 3 deletions

View File

@@ -2064,6 +2064,14 @@ class nullcontext:
pass
def traceback_format_exception(exc: BaseException) -> Sequence[str]:
"""Compatibility wrapper for stdlib traceback.format_exception using python 3.10+ API."""
if sys.version_info[:3] >= (3, 10):
return traceback.format_exception(exc)
else:
return traceback.format_exception(type(exc), value=exc, tb=exc.__traceback__)
class classproperty(property):
"""~read-only class-level @property
from https://stackoverflow.com/a/13624858 by denis-ryzhkov