Issue46234
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2022-01-02 23:14 by nedbat, last changed 2022-04-11 14:59 by admin.
Messages (1) | |||
---|---|---|---|
msg409539 - (view) | Author: Ned Batchelder (nedbat) * | Date: 2022-01-02 23:14 | |
Sometime after 3.11.0a3, tracing of decorators changed so that each decorator line is revisited as the decorator is invoked. Is this intentional? ---< dectrace.py >----------------------------------- import linecache, sys def trace(frame, event, arg): # The weird globals here is to avoid a NameError on shutdown... if frame.f_code.co_filename == globals().get("__file__"): lineno = frame.f_lineno print("{} {}: {}".format(event[:4], lineno, linecache.getline(__file__, lineno).rstrip())) return trace print(sys.version) sys.settrace(trace) def decorator(func): return func def doit(): @decorator @decorator @decorator def func(x): return x + 1 print(func(1)) doit() ----------------------------------------------------- Running it on 3.10, 3.11.0a3, and latest 3.11. The last run has the new line hightlighted with <<<<<: $ python3.10 dectrace.py 3.10.1 (main, Dec 14 2021, 08:30:13) [Clang 12.0.0 (clang-1200.0.32.29)] call 16: def doit(): line 17: @decorator line 18: @decorator line 19: @decorator line 20: def func(x): call 13: def decorator(func): line 14: return func retu 14: return func call 13: def decorator(func): line 14: return func retu 14: return func call 13: def decorator(func): line 14: return func retu 14: return func line 23: print(func(1)) call 17: @decorator line 21: return x + 1 retu 21: return x + 1 2 retu 23: print(func(1)) $ python3.11 dectrace.py 3.11.0a3 (main, Dec 9 2021, 12:22:18) [Clang 12.0.0 (clang-1200.0.32.29)] call 16: def doit(): line 17: @decorator line 18: @decorator line 19: @decorator line 20: def func(x): call 13: def decorator(func): line 14: return func retu 14: return func call 13: def decorator(func): line 14: return func retu 14: return func call 13: def decorator(func): line 14: return func retu 14: return func line 23: print(func(1)) call 17: @decorator line 21: return x + 1 retu 21: return x + 1 2 retu 23: print(func(1)) $ /usr/local/cpython/bin/python3.11 dectrace.py 3.11.0a3+ (heads/main:a82baed0e9, Jan 2 2022, 08:12:01) [Clang 12.0.0 (clang-1200.0.32.29)] call 16: def doit(): line 17: @decorator line 18: @decorator line 19: @decorator line 20: def func(x): line 19: @decorator <<<<< call 13: def decorator(func): line 14: return func retu 14: return func line 18: @decorator <<<<< call 13: def decorator(func): line 14: return func retu 14: return func line 17: @decorator <<<<< call 13: def decorator(func): line 14: return func retu 14: return func line 20: def func(x): line 23: print(func(1)) call 17: @decorator line 21: return x + 1 retu 21: return x + 1 2 retu 23: print(func(1)) (this might or might not be related to https://bugs.python.org/issue37971) |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:59:54 | admin | set | github: 90392 |
2022-01-02 23:14:57 | nedbat | create |