Commit 03fff78e authored by Felix Kohlgrüber's avatar Felix Kohlgrüber

fix co_firstlineno for functions that have decorators

parent 336d8ca7
......@@ -3367,7 +3367,7 @@ def _reject_cdef_modifier_in_py(s, name):
def p_def_statement(s, decorators=None, is_async_def=False):
# s.sy == 'def'
pos = s.position()
pos = decorators[0].pos if decorators else s.position()
# PEP 492 switches the async/await keywords on in "async def" functions
if is_async_def:
s.enter_async()
......
......@@ -391,3 +391,22 @@ cdef class TestOptimisedBuiltinMethod:
def call(self, arg, obj=None):
(obj or self).append(arg+1) # optimistically optimised => uses fast fallback method call
def do_nothing(f):
"""Dummy decorator for `test_firstlineno_decorated_function`"""
return f
@do_nothing
@do_nothing
def test_firstlineno_decorated_function():
"""
check that `test_firstlineno_decorated_function` starts 5 lines below `do_nothing`
>>> test_firstlineno_decorated_function()
5
"""
l1 = do_nothing.__code__.co_firstlineno
l2 = test_firstlineno_decorated_function.__code__.co_firstlineno
return l2 - l1
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment