Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apport ExeptHook detection stopped working. #2464

Closed
Xyaren opened this issue Nov 7, 2022 · 2 comments · Fixed by #2838
Closed

Apport ExeptHook detection stopped working. #2464

Xyaren opened this issue Nov 7, 2022 · 2 comments · Fixed by #2838

Comments

@Xyaren
Copy link

Xyaren commented Nov 7, 2022

The detection via the name apport_excepthook introduced in #1065,#1528 stopped working for me.
Checking my system it seems apport has changed the name:

>>> import sys
>>> sys.excepthook.__name__
'partial_apport_excepthook'

Relevant change: canonical/apport@ad6d801#diff-262abd69bbc20e14d09d4b9041c97e2586e3f3f3db59acf4389b2485abe6dd7cR233

I suggest adding both names to the detection.

This started after updating from Ubuntu 22.04 to Ubuntu 22.10.

Thanks!

Paging @pquentin, as you are the original Author of the workaround.

@Zac-HD
Copy link
Member

Zac-HD commented Mar 16, 2023

See #1553, agronholm/exceptiongroup#23 and

# Ubuntu's system Python has a sitecustomize.py file that import
# apport_python_hook and replaces sys.excepthook.
#
# The custom hook captures the error for crash reporting, and then calls
# sys.__excepthook__ to actually print the error.
#
# We don't mind it capturing the error for crash reporting, but we want to
# take over printing the error. So we monkeypatch the apport_python_hook
# module so that instead of calling sys.__excepthook__, it calls our custom
# hook.
#
# More details: https://github.com/python-trio/trio/issues/1065
if (
sys.version_info < (3, 11)
and getattr(sys.excepthook, "__name__", None) == "apport_excepthook"
):
from types import ModuleType
import apport_python_hook
from exceptiongroup import format_exception
assert sys.excepthook is apport_python_hook.apport_excepthook
def replacement_excepthook(etype, value, tb):
sys.stderr.write("".join(format_exception(etype, value, tb)))
fake_sys = ModuleType("trio_fake_sys")
fake_sys.__dict__.update(sys.__dict__)
fake_sys.__excepthook__ = replacement_excepthook # type: ignore
apport_python_hook.sys = fake_sys

@A5rocks
Copy link
Contributor

A5rocks commented Oct 29, 2023

Oh, I just invoked python wrong. My bad. (needed to do /usr/bin/env python3 and not python3... :( )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants