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
Kirill Smelkov
cython
Commits
9906ab9c
Commit
9906ab9c
authored
Jun 19, 2017
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow undeclared narrower return for cdef methods.
parent
68a4db26
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
5 deletions
+19
-5
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+9
-4
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+2
-1
tests/errors/cmethbasematch.pxd
tests/errors/cmethbasematch.pxd
+3
-0
tests/errors/cmethbasematch.pyx
tests/errors/cmethbasematch.pyx
+5
-0
No files found.
Cython/Compiler/PyrexTypes.py
View file @
9906ab9c
...
...
@@ -2553,11 +2553,11 @@ class CFuncType(CType):
def
as_argument_type
(
self
):
return
c_ptr_type
(
self
)
def
same_c_signature_as
(
self
,
other_type
,
as_cmethod
=
0
):
def
same_c_signature_as
(
self
,
other_type
,
as_cmethod
=
0
,
as_pxd_definition
=
0
):
return
self
.
same_c_signature_as_resolved_type
(
other_type
.
resolve
(),
as_cmethod
)
def
same_c_signature_as_resolved_type
(
self
,
other_type
,
as_cmethod
=
0
):
def
same_c_signature_as_resolved_type
(
self
,
other_type
,
as_cmethod
=
0
,
as_pxd_definition
=
0
):
#print "CFuncType.same_c_signature_as_resolved_type:", \
# self, other_type, "as_cmethod =", as_cmethod ###
if
other_type
is
error_type
:
...
...
@@ -2579,8 +2579,13 @@ class CFuncType(CType):
return
0
if
self
.
optional_arg_count
!=
other_type
.
optional_arg_count
:
return
0
if
not
self
.
return_type
.
same_as
(
other_type
.
return_type
):
return
0
if
as_pxd_definition
:
# A narrowing of the return type declared in the pxd is allowed.
if
not
self
.
return_type
.
subtype_of_resolved_type
(
other_type
.
return_type
):
return
0
else
:
if
not
self
.
return_type
.
same_as
(
other_type
.
return_type
):
return
0
if
not
self
.
same_calling_convention_as
(
other_type
):
return
0
if
self
.
exception_check
!=
other_type
.
exception_check
:
...
...
Cython/Compiler/Symtab.py
View file @
9906ab9c
...
...
@@ -2094,7 +2094,8 @@ class CClassScope(ClassScope):
# Fix with_gil vs nogil.
entry
.
type
=
entry
.
type
.
with_with_gil
(
type
.
with_gil
)
elif
type
.
compatible_signature_with
(
entry
.
type
,
as_cmethod
=
1
)
and
type
.
nogil
==
entry
.
type
.
nogil
:
if
self
.
defined
and
not
in_pxd
:
if
(
self
.
defined
and
not
in_pxd
and
not
type
.
same_c_signature_as_resolved_type
(
entry
.
type
,
as_cmethod
=
1
,
as_pxd_definition
=
1
)):
error
(
pos
,
"Compatible but non-identical C method '%s' not redeclared "
"in definition part of extension type '%s'"
%
(
name
,
self
.
class_name
))
...
...
tests/errors/cmethbasematch.pxd
View file @
9906ab9c
...
...
@@ -6,3 +6,6 @@ cdef class MissingRedeclaration(Base):
cdef
class
BadRedeclaration
(
Base
):
cdef
f
(
self
)
cdef
class
NarrowerReturn
(
Base
):
pass
tests/errors/cmethbasematch.pyx
View file @
9906ab9c
...
...
@@ -28,6 +28,11 @@ cdef class UnneededRedeclaration(Base):
cpdef
f
(
self
):
pass
cdef
class
NarrowerReturn
(
Base
):
# This does not require a new vtable entry.
cdef
Base
f
(
self
):
pass
_ERRORS
=
u"""
8: 9: Signature not compatible with previous declaration
...
...
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