Skip to content

Commit c2ca18d

Browse files
Move monitoring after method expand for CALL_KW
1 parent 6c450f4 commit c2ca18d

File tree

3 files changed

+44
-28
lines changed

3 files changed

+44
-28
lines changed

Lib/test/test_sys_setprofile.py

+18
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,24 @@ class A:
493493
# The last c_call is the call to sys.setprofile
494494
self.assertEqual(events, ['c_call', 'c_return', 'c_call'])
495495

496+
class B:
497+
f = classmethod(max)
498+
events = []
499+
sys.setprofile(lambda frame, event, args: events.append(event))
500+
# Not important, we only want to trigger INSTRUMENTED_CALL_KW
501+
B().f(1, key=lambda x: 0)
502+
sys.setprofile(None)
503+
# The last c_call is the call to sys.setprofile
504+
self.assertEqual(
505+
events,
506+
['c_call',
507+
'call', 'return',
508+
'call', 'return',
509+
'c_return',
510+
'c_call'
511+
]
512+
)
513+
496514

497515
if __name__ == "__main__":
498516
unittest.main()

Python/bytecodes.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4509,8 +4509,8 @@ dummy_func(
45094509
macro(INSTRUMENTED_CALL_KW) =
45104510
counter/1 +
45114511
unused/2 +
4512-
_MONITOR_CALL_KW +
45134512
_MAYBE_EXPAND_METHOD_KW +
4513+
_MONITOR_CALL_KW +
45144514
_DO_CALL_KW;
45154515

45164516
op(_CHECK_IS_NOT_PY_CALLABLE_KW, (callable[1], unused[1], unused[oparg], kwnames -- callable[1], unused[1], unused[oparg], kwnames)) {

Python/generated_cases.c.h

+25-27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)