Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
03fff78e
Commit
03fff78e
authored
Oct 27, 2018
by
Felix Kohlgrüber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix co_firstlineno for functions that have decorators
parent
336d8ca7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+1
-1
tests/run/cyfunction.pyx
tests/run/cyfunction.pyx
+19
-0
No files found.
Cython/Compiler/Parsing.py
View file @
03fff78e
...
...
@@ -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
()
...
...
tests/run/cyfunction.pyx
View file @
03fff78e
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment