| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -1718,3 +1718,31 @@ def make_foo_optimized_then_set_event(): | |
| make_foo_optimized_then_set_event() | ||
| finally: | ||
| sys.monitoring.set_events(TEST_TOOL, 0) | ||
|
|
||
|
|
||
| class TestOptimizer(MonitoringTestBase, unittest.TestCase): | ||
|
|
||
| def setUp(self): | ||
| import _testinternalcapi | ||
| self.old_opt = _testinternalcapi.get_optimizer() | ||
| opt = _testinternalcapi.get_counter_optimizer() | ||
| _testinternalcapi.set_optimizer(opt) | ||
| super(TestOptimizer, self).setUp() | ||
|
|
||
| def tearDown(self): | ||
| import _testinternalcapi | ||
| super(TestOptimizer, self).tearDown() | ||
| _testinternalcapi.set_optimizer(self.old_opt) | ||
|
|
||
| def test_for_loop(self): | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI'd like @markshannon to review this part at least.
Sorry, something went wrong.
All reactions
|
||
| def test_func(x): | ||
| i = 0 | ||
| while i < x: | ||
| i += 1 | ||
|
|
||
| code = test_func.__code__ | ||
| sys.monitoring.set_local_events(TEST_TOOL, code, E.PY_START) | ||
| self.assertEqual(sys.monitoring.get_local_events(TEST_TOOL, code), E.PY_START) | ||
| test_func(1000) | ||
| sys.monitoring.set_local_events(TEST_TOOL, code, 0) | ||
| self.assertEqual(sys.monitoring.get_local_events(TEST_TOOL, code), 0) | ||
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality@markshannon cc @gvanrossum
I added a test, but not sure what you wanted :)
Without this PR, Python/instrumentation.c#L1589 will not be able to pass the assert through this test.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWhat is this test supposed to do? When I copy this test into the main branch, it passes (in debug mode, so failing asserts would cause crashes), so I don't think this proves your fix works.
By adding some dis.dis(test_func, adaptive=True) calls to the test I think I see the difference -- in main, an ENTER_EXECUTOR opcode remains in the code object, whereas with this PR, the ENTER_EXECUTOR opcode appears after the function is called, but disappears again after the second set_local_events call.
You could check for that ENTER_EXECUTOR (there are examples in test_capi/test_misc.py) but it would be nice if you had example code that actually crashed or triggered an assert (in debug mode) in main without your fix.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityHmm,, interesting, It looks like I watched the Hallucination when I wrote the test in the first place :(
I will soon update the PR.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualitySee: #108539 (comment)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.