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.

Author control-k
Recipients control-k
Date 2019-08-28.18:32:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1567017172.25.0.486267767179.issue37971@roundup.psfhosted.org>
In-reply-to
Content
When applying multiple decorators to a function, a traceback from the top generator shows the bottom generator instead.
For example

----------------
def printingdec(f):
    raise Exception()
    return f

def dummydec(f):
    return f

@printingdec
@dummydec
def foo():
    pass
----------------

gives
Traceback (most recent call last):
  File "bug.py", line 9, in <module>
    @dummydec
  File "bug.py", line 2, in printingdec
    raise Exception()
Exception

instead of
Traceback (most recent call last):
  File "bug.py", line 8, in <module>
    @printingdec
  File "bug.py", line 2, in printingdec
    raise Exception()
Exception


Digging around with sys._getframe() it seems that the frame's linenumber is set wrong internally, leading to the wrong line being displayed.
The ast does display the correct linenumber.
History
Date User Action Args
2019-08-28 18:32:52control-ksetrecipients: + control-k
2019-08-28 18:32:52control-ksetmessageid: <1567017172.25.0.486267767179.issue37971@roundup.psfhosted.org>
2019-08-28 18:32:52control-klinkissue37971 messages
2019-08-28 18:32:52control-kcreate