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
ea0cbaf7
Commit
ea0cbaf7
authored
Dec 21, 2016
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly handle nogil vs. withgil overrides.
parent
92f222b9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+13
-3
tests/compile/cpp_nogil.pyx
tests/compile/cpp_nogil.pyx
+5
-0
No files found.
Cython/Compiler/Symtab.py
View file @
ea0cbaf7
...
...
@@ -734,7 +734,11 @@ class Scope(object):
if
overridable
!=
entry
.
is_overridable
:
warning
(
pos
,
"Function '%s' previously declared as '%s'"
%
(
name
,
'cpdef'
if
overridable
else
'cdef'
),
1
)
if
not
entry
.
type
.
same_as
(
type
):
if
entry
.
type
.
same_as
(
type
):
# Compatible signatures may have still be different types
# (e.g. nogil vs with gil).
entry
.
type
=
type
else
:
if
visibility
==
'extern'
and
entry
.
visibility
==
'extern'
:
can_override
=
False
if
self
.
is_cpp
():
...
...
@@ -2081,7 +2085,9 @@ class CClassScope(ClassScope):
if
entry
.
is_final_cmethod
and
entry
.
is_inherited
:
error
(
pos
,
"Overriding final methods is not allowed"
)
elif
type
.
same_c_signature_as
(
entry
.
type
,
as_cmethod
=
1
)
and
type
.
nogil
==
entry
.
type
.
nogil
:
pass
# Compatible signatures may have still be different types
# (e.g. nogil vs with gil).
entry
.
type
=
type
elif
type
.
compatible_signature_with
(
entry
.
type
,
as_cmethod
=
1
)
and
type
.
nogil
==
entry
.
type
.
nogil
:
entry
=
self
.
add_cfunction
(
name
,
type
,
pos
,
cname
,
visibility
=
'ignore'
,
modifiers
=
modifiers
)
else
:
...
...
@@ -2215,7 +2221,11 @@ class CppClassScope(Scope):
cname
=
name
entry
=
self
.
lookup_here
(
name
)
if
defining
and
entry
is
not
None
:
if
not
entry
.
type
.
same_as
(
type
):
if
entry
.
type
.
same_as
(
type
):
# Compatible signatures may have still be different types
# (e.g. nogil vs with gil).
entry
.
type
=
type
else
:
error
(
pos
,
"Function signature does not match previous declaration"
)
else
:
entry
=
self
.
declare
(
name
,
cname
,
type
,
pos
,
visibility
)
...
...
tests/compile/cpp_nogil.pyx
View file @
ea0cbaf7
...
...
@@ -16,3 +16,8 @@ cdef extern from *:
with
nogil
:
NoGilTest1
().
doSomething
()
NoGilTest2
().
doSomething
()
# We can override nogil methods as with gil methods.
cdef
cppclass
WithGilSubclass
(
NoGilTest1
):
void
doSomething
()
with
gil
:
print
"have the gil"
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