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

Remove INSTRUCTION event monitoring will remove LINE events as well #109156

Closed
gaogaotiantian opened this issue Sep 8, 2023 · 4 comments
Closed
Labels
type-bug An unexpected behavior, bug, or error

Comments

@gaogaotiantian
Copy link
Member

gaogaotiantian commented Sep 8, 2023

Bug report

Bug description:

The current de-instrumentation code for instructions incorrectly de-instruments line too. So if INSTRUCTION events are removed, event if the LINE events are still there, it won't trigger the event.

import sys
E = sys.monitoring.events

def line(*args):
    print("Line event: ", args)

def inst(*args):
    print("Instruction event: ", args)

sys.monitoring.use_tool_id(0, "test")
sys.monitoring.set_events(0, 0)
sys.monitoring.register_callback(0, E.LINE, line)
sys.monitoring.register_callback(0, E.INSTRUCTION, inst)
sys.monitoring.set_events(0, E.LINE | E.INSTRUCTION)
sys.monitoring.set_events(0, E.LINE)
a = 1
sys.monitoring.set_events(0, 0)

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

@markshannon
Copy link
Member

#109131 fixes this.
We should add the test in #109157 though.

@gaogaotiantian
Copy link
Member Author

#109131 fixes this. We should add the test in #109157 though.

Do you want me to only keep the test in the PR? I can rename the PR to "add tests" and maybe skip the news?

@markshannon
Copy link
Member

Yes, please. We are obviously lacking a test for this.

@markshannon
Copy link
Member

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants