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
499fd678
Commit
499fd678
authored
Jan 16, 2019
by
mattip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MAINT: fixes from review
parent
ccb67088
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
20 deletions
+33
-20
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-1
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+15
-12
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+1
-2
tests/run/ext_attr_getter.srctree
tests/run/ext_attr_getter.srctree
+16
-5
No files found.
Cython/Compiler/ExprNodes.py
View file @
499fd678
...
...
@@ -7147,7 +7147,7 @@ class AttributeNode(ExprNode):
#print "...obj_code =", obj_code ###
if
self
.
entry
and
self
.
entry
.
is_cmethod
:
if
self
.
entry
.
is_cgetter
:
return
"%s(%s)"
%
(
self
.
entry
.
func_cname
,
obj_code
)
return
"%s(%s)"
%
(
self
.
entry
.
func_cname
,
obj_code
)
if
obj
.
type
.
is_extension_type
and
not
self
.
entry
.
is_builtin_cmethod
:
if
self
.
entry
.
final_func_cname
:
return
self
.
entry
.
final_func_cname
...
...
Cython/Compiler/Nodes.py
View file @
499fd678
...
...
@@ -2351,6 +2351,9 @@ class CFuncDefNode(FuncDefNode):
pass
else
:
error
(
self
.
pos
,
"Cannot handle %s decorators yet"
%
func
.
name
)
else
:
error
(
self
.
pos
,
"Cannot handle %s decorators yet"
%
type
(
func
).
__name__
)
self
.
is_c_class_method
=
env
.
is_c_class_scope
if
self
.
directive_locals
is
None
:
...
...
@@ -2366,20 +2369,20 @@ class CFuncDefNode(FuncDefNode):
self
.
is_static_method
=
'staticmethod'
in
env
.
directives
and
not
env
.
lookup_here
(
'staticmethod'
)
# The 2 here is because we need both function and argument names.
if
isinstance
(
self
.
declarator
,
CFuncDeclaratorNode
):
name_declarator
,
typ
e
=
self
.
declarator
.
analyse
(
name_declarator
,
typ
=
self
.
declarator
.
analyse
(
base_type
,
env
,
nonempty
=
2
*
(
self
.
body
is
not
None
),
directive_locals
=
self
.
directive_locals
,
visibility
=
self
.
visibility
)
else
:
name_declarator
,
typ
e
=
self
.
declarator
.
analyse
(
name_declarator
,
typ
=
self
.
declarator
.
analyse
(
base_type
,
env
,
nonempty
=
2
*
(
self
.
body
is
not
None
),
visibility
=
self
.
visibility
)
if
not
typ
e
.
is_cfunction
:
if
not
typ
.
is_cfunction
:
error
(
self
.
pos
,
"Suite attached to non-function declaration"
)
# Remember the actual type according to the function header
# written here, because the type in the symbol table entry
# may be different if we're overriding a C method inherited
# from the base type of an extension type.
self
.
type
=
typ
e
typ
e
.
is_overridable
=
self
.
overridable
self
.
type
=
typ
typ
.
is_overridable
=
self
.
overridable
declarator
=
self
.
declarator
while
not
hasattr
(
declarator
,
'args'
):
declarator
=
declarator
.
base
...
...
@@ -2392,11 +2395,11 @@ class CFuncDefNode(FuncDefNode):
error
(
self
.
cfunc_declarator
.
pos
,
"Function with optional arguments may not be declared public or api"
)
if
typ
e
.
exception_check
==
'+'
and
self
.
visibility
!=
'extern'
:
if
typ
.
exception_check
==
'+'
and
self
.
visibility
!=
'extern'
:
warning
(
self
.
cfunc_declarator
.
pos
,
"Only extern functions can throw C++ exceptions."
)
for
formal_arg
,
type_arg
in
zip
(
self
.
args
,
typ
e
.
args
):
for
formal_arg
,
type_arg
in
zip
(
self
.
args
,
typ
.
args
):
self
.
align_argument_type
(
env
,
type_arg
)
formal_arg
.
type
=
type_arg
.
type
formal_arg
.
name
=
type_arg
.
name
...
...
@@ -2417,16 +2420,16 @@ class CFuncDefNode(FuncDefNode):
elif
'inline'
in
self
.
modifiers
:
warning
(
formal_arg
.
pos
,
"Buffer unpacking not optimized away."
,
1
)
self
.
_validate_type_visibility
(
typ
e
.
return_type
,
self
.
pos
,
env
)
self
.
_validate_type_visibility
(
typ
.
return_type
,
self
.
pos
,
env
)
name
=
name_declarator
.
name
cname
=
name_declarator
.
cname
typ
e
.
is_const_method
=
self
.
is_const_method
typ
e
.
is_static_method
=
self
.
is_static_method
typ
.
is_const_method
=
self
.
is_const_method
typ
.
is_static_method
=
self
.
is_static_method
self
.
entry
=
env
.
declare_cfunction
(
name
,
typ
e
,
self
.
pos
,
name
,
typ
,
self
.
pos
,
cname
=
cname
,
visibility
=
self
.
visibility
,
api
=
self
.
api
,
defining
=
self
.
body
is
not
None
,
modifiers
=
self
.
modifiers
,
overridable
=
self
.
overridable
)
...
...
@@ -2435,7 +2438,7 @@ class CFuncDefNode(FuncDefNode):
env
.
property_entries
.
append
(
self
.
entry
)
env
.
cfunc_entries
.
remove
(
self
.
entry
)
self
.
entry
.
inline_func_in_pxd
=
self
.
inline_in_pxd
self
.
return_type
=
typ
e
.
return_type
self
.
return_type
=
typ
.
return_type
if
self
.
return_type
.
is_array
and
self
.
visibility
!=
'extern'
:
error
(
self
.
pos
,
"Function cannot return an array"
)
if
self
.
return_type
.
is_cpp_class
:
...
...
Cython/Compiler/Symtab.py
View file @
499fd678
...
...
@@ -754,8 +754,7 @@ class Scope(object):
def
declare_cfunction
(
self
,
name
,
type
,
pos
,
cname
=
None
,
visibility
=
'private'
,
api
=
0
,
in_pxd
=
0
,
defining
=
0
,
modifiers
=
(),
utility_code
=
None
,
overridable
=
False
):
defining
=
0
,
modifiers
=
(),
utility_code
=
None
,
overridable
=
False
):
# Add an entry for a C function.
if
not
cname
:
if
visibility
!=
'private'
or
api
:
...
...
tests/run/ext_attr_getter.srctree
View file @
499fd678
...
...
@@ -12,11 +12,12 @@ setup(ext_modules= cythonize("foo_extension.pyx", language_level=3))
setup(ext_modules = cythonize("getter[0-9].pyx", language_level=3))
try:
cythonize("getter_fail0.pyx", language_level=3)
assert False
except CompileError:
print("\nGot expected exception, continuing\n")
for name in ("getter_fail0.pyx", "getter_fail1.pyx"):
try:
cythonize(name, language_level=3)
assert False
except CompileError as e:
print("\nGot expected exception, continuing\n")
######## foo.h ########
...
...
@@ -154,6 +155,16 @@ cdef extern from "foo.h":
cdef void field0():
print('in staticmethod of Foo')
######## getter_fail1.pyx ########
# Make sure not all decorators are accepted
cimport cython
cdef extern from "foo.h":
ctypedef class foo_extension.Foo [object FooStructOpaque]:
@prop.getter
cdef void field0(self):
pass
######## runner.py ########
...
...
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