Skip to content

No sys.monitoring RAISE event emitted when exception is re-raised (3.12b4) #106897

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

Closed
jpe opened this issue Jul 19, 2023 · 1 comment
Closed

No sys.monitoring RAISE event emitted when exception is re-raised (3.12b4) #106897

jpe opened this issue Jul 19, 2023 · 1 comment
Assignees
Labels
3.12 only security fixes 3.13 bugs and security fixes type-bug An unexpected behavior, bug, or error

Comments

@jpe
Copy link

jpe commented Jul 19, 2023

It looks like no RAISE event is emitted for a bare raise in an except: clause or at the end of a finally: clause that implicitly reraises an exception. I don't know whether this a problem with the implementation or it should simply be documented that this is to be expected.

I mentioned this in #103082 but was encouraged to create a separate bug for it.

Linked PRs

@jpe jpe added the type-bug An unexpected behavior, bug, or error label Jul 19, 2023
@AlexWaygood AlexWaygood added 3.12 only security fixes 3.13 bugs and security fixes labels Jul 19, 2023
@markshannon
Copy link
Member

markshannon commented Jul 26, 2023

We should emit an event for these cases, as the "exception raised" events, and "exception handled" events should balance.
There are quite a lot of exception events during unwinding however, so this could be quite noisy.

For example:

def func():
    try:
        try:
            1/0
        except:
            raise
    except:
        pass

generates 3 raise/handled pairs. The obvious 2, plus another for cleanup, which is highly implementation dependent.
If we generate normal RAISE events it will break sys.settrace, so we need to emit a different event.
RERAISE is the obvious name.

markshannon added a commit that referenced this issue Jul 27, 2023
* Ensures that exception handling events are balanced. Each [re]raise event has a matching unwind/handled event.
markshannon added a commit to faster-cpython/cpython that referenced this issue Jul 27, 2023
…07291)

* Ensures that exception handling events are balanced. Each [re]raise event has a matching unwind/handled event.
markshannon added a commit that referenced this issue Jul 28, 2023
GH-107346)

* Ensures that exception handling events are balanced. Each [re]raise event has a matching unwind/handled event.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 only security fixes 3.13 bugs and security fixes type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants