Message326921
When decorating a function, the sequence of lines reported to the trace function is different in Python3.8 than with previous versions
$ cat -n decorator.py
1 def decorator(f):
2 return f
3
4 def f():
5 @decorator
6 @decorator
7 @decorator
8 def func():
9 pass
10
11 import sys
12 def trace(frame, event, args):
13 print(frame.f_lineno, event)
14 return trace
15
16 sys.settrace(trace)
17 f()
$ python3.7 decorator.py
4 call
5 line
6 line
7 line
1 call
2 line
2 return
1 call
2 line
2 return
1 call
2 line
2 return
7 return
$ python3.8 decorator.py
4 call
5 line
6 line
7 line
5 line
1 call
2 line
2 return
1 call
2 line
2 return
1 call
2 line
2 return
5 return
Is this intentional? Will it be changed back before 3.8 ships?
People are testing their projects against 3.8-dev, and reporting problems with coverage. The problems are due to these sorts of changes. |
|
Date |
User |
Action |
Args |
2018-10-02 23:06:44 | nedbat | set | recipients:
+ nedbat |
2018-10-02 23:06:44 | nedbat | set | messageid: <1538521604.52.0.545547206417.issue34876@psf.upfronthosting.co.za> |
2018-10-02 23:06:44 | nedbat | link | issue34876 messages |
2018-10-02 23:06:44 | nedbat | create | |
|