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
990e1a15
Commit
990e1a15
authored
Feb 15, 2019
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent crash when accessing the "__kwdefaults__" special attribute of fused functions.
Closes #1470.
parent
40ad34a0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletion
+33
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-1
tests/run/fused_def.pyx
tests/run/fused_def.pyx
+31
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
990e1a15
...
@@ -9460,7 +9460,8 @@ class PyCFunctionNode(ExprNode, ModuleNameMixin):
...
@@ -9460,7 +9460,8 @@ class PyCFunctionNode(ExprNode, ModuleNameMixin):
if
self
.
defaults_kwdict
:
if
self
.
defaults_kwdict
:
code
.
putln
(
'__Pyx_CyFunction_SetDefaultsKwDict(%s, %s);'
%
(
code
.
putln
(
'__Pyx_CyFunction_SetDefaultsKwDict(%s, %s);'
%
(
self
.
result
(),
self
.
defaults_kwdict
.
py_result
()))
self
.
result
(),
self
.
defaults_kwdict
.
py_result
()))
if
def_node
.
defaults_getter
:
if
def_node
.
defaults_getter
and
not
self
.
specialized_cpdefs
:
# Fused functions do not support dynamic defaults, only their specialisations can have them for now.
code
.
putln
(
'__Pyx_CyFunction_SetDefaultsGetter(%s, %s);'
%
(
code
.
putln
(
'__Pyx_CyFunction_SetDefaultsGetter(%s, %s);'
%
(
self
.
result
(),
def_node
.
defaults_getter
.
entry
.
pyfunc_cname
))
self
.
result
(),
def_node
.
defaults_getter
.
entry
.
pyfunc_cname
))
if
self
.
annotations_dict
:
if
self
.
annotations_dict
:
...
...
tests/run/fused_def.pyx
View file @
990e1a15
...
@@ -58,12 +58,21 @@ def opt_func(fused_t obj, cython.floating myf = 1.2, cython.integral myi = 7):
...
@@ -58,12 +58,21 @@ def opt_func(fused_t obj, cython.floating myf = 1.2, cython.integral myi = 7):
>>> opt_func("spam", f, i)
>>> opt_func("spam", f, i)
str object double long
str object double long
spam 5.60 9 5.60 9
spam 5.60 9 5.60 9
>>> opt_func("spam", f, myi=i)
str object double long
spam 5.60 9 5.60 9
>>> opt_func("spam", myf=f, myi=i)
str object double long
spam 5.60 9 5.60 9
>>> opt_func[str, float, int]("spam", f, i)
>>> opt_func[str, float, int]("spam", f, i)
str object float int
str object float int
spam 5.60 9 5.60 9
spam 5.60 9 5.60 9
>>> opt_func[str, cy.double, cy.long]("spam", f, i)
>>> opt_func[str, cy.double, cy.long]("spam", f, i)
str object double long
str object double long
spam 5.60 9 5.60 9
spam 5.60 9 5.60 9
>>> opt_func[str, cy.double, cy.long]("spam", f, myi=i)
str object double long
spam 5.60 9 5.60 9
>>> opt_func[str, float, cy.int]("spam", f, i)
>>> opt_func[str, float, cy.int]("spam", f, i)
str object float int
str object float int
spam 5.60 9 5.60 9
spam 5.60 9 5.60 9
...
@@ -129,6 +138,28 @@ def test_opt_func():
...
@@ -129,6 +138,28 @@ def test_opt_func():
opt_func
(
"ham"
,
f
,
entry4
)
opt_func
(
"ham"
,
f
,
entry4
)
def
test_opt_func_introspection
():
"""
>>> opt_func.__defaults__
(1.2, 7)
>>> opt_func.__kwdefaults__
>>> opt_func.__annotations__
{}
>>> opt_func[str, float, int].__defaults__
(1.2, 7)
>>> opt_func[str, float, int].__kwdefaults__
>>> opt_func[str, float, int].__annotations__
{}
>>> opt_func[str, cy.double, cy.long].__defaults__
(1.2, 7)
>>> opt_func[str, cy.double, cy.long].__kwdefaults__
>>> opt_func[str, cy.double, cy.long].__annotations__
{}
"""
def
func_with_object
(
fused_with_object
obj
,
cython
.
integral
myi
=
7
):
def
func_with_object
(
fused_with_object
obj
,
cython
.
integral
myi
=
7
):
"""
"""
>>> func_with_object(1)
>>> func_with_object(1)
...
...
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