Author nedbat
Recipients ammar2, nedbat, serhiy.storchaka, terry.reedy
Date 2018-10-05.20:55:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1538772927.79.0.545547206417.issue34876@psf.upfronthosting.co.za>
In-reply-to
Content
This is the --trace output for some stacked decorators:

$ cat -n /tmp/decdec.py
     1	def decorator1(f):
     2	    return f
     3
     4	def decorator2(f):
     5	    return f
     6
     7	def decorator3(f):
     8	    return f
     9
    10	@decorator1
    11	@decorator2
    12	@decorator3
    13	def func():
    14	    print("hello")
    15
    16	func()

$ python3.7 -m trace --trace /tmp/decdec.py
 --- modulename: decdec, funcname: <module>
decdec.py(1): def decorator1(f):
decdec.py(4): def decorator2(f):
decdec.py(7): def decorator3(f):
decdec.py(10): @decorator1
decdec.py(11): @decorator2
decdec.py(12): @decorator3
 --- modulename: decdec, funcname: decorator3
decdec.py(8):     return f
 --- modulename: decdec, funcname: decorator2
decdec.py(5):     return f
 --- modulename: decdec, funcname: decorator1
decdec.py(2):     return f
decdec.py(16): func()
 --- modulename: decdec, funcname: func
decdec.py(14):     print("hello")
hello

$ python3.8 -m trace --trace /tmp/decdec.py
 --- modulename: decdec, funcname: <module>
decdec.py(1): def decorator1(f):
decdec.py(4): def decorator2(f):
decdec.py(7): def decorator3(f):
decdec.py(10): @decorator1
decdec.py(11): @decorator2
decdec.py(12): @decorator3
decdec.py(10): @decorator1
 --- modulename: decdec, funcname: decorator3
decdec.py(8):     return f
 --- modulename: decdec, funcname: decorator2
decdec.py(5):     return f
 --- modulename: decdec, funcname: decorator1
decdec.py(2):     return f
decdec.py(16): func()
 --- modulename: decdec, funcname: func
decdec.py(14):     print("hello")
hello


In Python3.8, "@decorator1" appears twice, as both the first and the last decorator line traced.  There's no conceptual reason to show that line twice.

I'd like to consider the stacked decorator case separately from the multi-line function call case.  Yes, they are consequences of the same change.  One change can have good effects and bad effects.  We can do further work to eliminate the bad effects.
History
Date User Action Args
2018-10-05 20:55:27nedbatsetrecipients: + nedbat, terry.reedy, serhiy.storchaka, ammar2
2018-10-05 20:55:27nedbatsetmessageid: <1538772927.79.0.545547206417.issue34876@psf.upfronthosting.co.za>
2018-10-05 20:55:27nedbatlinkissue34876 messages
2018-10-05 20:55:27nedbatcreate