Skip to content
Snippets Groups Projects
Commit 7e410c48 authored by Nico Madysa's avatar Nico Madysa
Browse files

Adjust excdialog for Python 3.13.

Python 3.13 deprecates `TracebackException.exc_type`, so we make the
search for exception names more dynamic.
parent 019325be
No related branches found
No related tags found
1 merge request!5Fix EnvSpec check in envs.Metadata
Pipeline #10026810 passed
......@@ -77,7 +77,7 @@ def exception_dialog(
text,
parent=parent,
buttons=QtWidgets.QMessageBox.Close,
keywords=tuple(exc.exc_type.__name__ for exc in _iter_exc_chain(exception)),
keywords=_gather_keywords(exception),
)
dialog.setInformativeText("".join(exception.format_exception_only()))
dialog.setDetailedText("".join(exception.format()))
......@@ -190,6 +190,18 @@ class _TracebackHighlighter(QtGui.QSyntaxHighlighter):
self.setFormat(match.capturedStart(0), match.capturedLength(0), Qt.red)
def _gather_keywords(exception: t.Optional[TracebackException]) -> tuple[str, ...]:
res = []
for exc in _iter_exc_chain(exception):
name = getattr(exc, "exc_type_str", None)
if name is None:
name = getattr(exc.exc_type, "__name__", None)
if name is None:
continue
res.append(name)
return tuple(res)
def _iter_exc_chain(
exc: t.Optional[TracebackException],
) -> t.Iterator[TracebackException]:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment