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
77cbab3a
Commit
77cbab3a
authored
Oct 13, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
merged fix for ticket #717 into master
parents
6bfb6480
847ef5d1
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
127 additions
and
78 deletions
+127
-78
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+103
-62
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+5
-2
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+4
-5
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+13
-7
tests/run/non_dict_kwargs_T470.pyx
tests/run/non_dict_kwargs_T470.pyx
+2
-2
No files found.
Cython/Compiler/ExprNodes.py
View file @
77cbab3a
This diff is collapsed.
Click to expand it.
Cython/Compiler/Nodes.py
View file @
77cbab3a
...
...
@@ -3386,9 +3386,12 @@ class PyClassDefNode(ClassDefNode):
# find metaclass" dance at runtime
self
.
metaclass
=
item
.
value
del
keyword_args
.
key_value_pairs
[
i
]
if
starstar_arg
or
(
keyword_args
and
keyword_args
.
key_value_pairs
)
:
if
starstar_arg
:
self
.
mkw
=
ExprNodes
.
KeywordArgsNode
(
pos
,
keyword_args
=
keyword_args
,
starstar_arg
=
starstar_arg
)
pos
,
keyword_args
=
keyword_args
and
keyword_args
.
key_value_pairs
or
[],
starstar_arg
=
starstar_arg
)
elif
keyword_args
and
keyword_args
.
key_value_pairs
:
self
.
mkw
=
keyword_args
else
:
self
.
mkw
=
ExprNodes
.
NullNode
(
pos
)
if
self
.
metaclass
is
None
:
...
...
Cython/Compiler/Optimize.py
View file @
77cbab3a
...
...
@@ -1638,9 +1638,6 @@ class EarlyReplaceBuiltinCalls(Visitor.EnvTransform):
return
node
if
not
isinstance
(
kwargs
,
ExprNodes
.
DictNode
):
return
node
if
node
.
starstar_arg
:
# we could optimize this by updating the kw dict instead
return
node
return
kwargs
...
...
@@ -1663,11 +1660,13 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
arg_tuple
=
node
.
positional_args
if
not
isinstance
(
arg_tuple
,
ExprNodes
.
TupleNode
):
return
node
if
node
.
starstar_arg
:
keyword_args
=
node
.
keyword_args
if
keyword_args
and
not
isinstance
(
keyword_args
,
ExprNodes
.
DictNode
):
# can't handle **kwargs
return
node
args
=
arg_tuple
.
args
return
self
.
_dispatch_to_handler
(
node
,
function
,
args
,
node
.
keyword_args
)
node
,
function
,
args
,
keyword_args
)
def
visit_SimpleCallNode
(
self
,
node
):
self
.
visitchildren
(
node
)
...
...
Cython/Compiler/Parsing.py
View file @
77cbab3a
...
...
@@ -440,7 +440,8 @@ def p_call_parse_args(s, allow_genexp = True):
s
.
expect
(
')'
)
return
positional_args
,
keyword_args
,
star_arg
,
starstar_arg
def
p_call_build_packed_args
(
pos
,
positional_args
,
keyword_args
,
star_arg
):
def
p_call_build_packed_args
(
pos
,
positional_args
,
keyword_args
,
star_arg
,
starstar_arg
=
None
):
arg_tuple
=
None
keyword_dict
=
None
if
positional_args
or
not
star_arg
:
...
...
@@ -454,11 +455,17 @@ def p_call_build_packed_args(pos, positional_args, keyword_args, star_arg):
operand2
=
star_arg_tuple
)
else
:
arg_tuple
=
star_arg_tuple
if
keyword_args
:
if
keyword_args
or
starstar_arg
:
keyword_args
=
[
ExprNodes
.
DictItemNode
(
pos
=
key
.
pos
,
key
=
key
,
value
=
value
)
for
key
,
value
in
keyword_args
]
keyword_dict
=
ExprNodes
.
DictNode
(
pos
,
key_value_pairs
=
keyword_args
)
if
starstar_arg
:
keyword_dict
=
ExprNodes
.
KeywordArgsNode
(
pos
,
starstar_arg
=
starstar_arg
,
keyword_args
=
keyword_args
)
else
:
keyword_dict
=
ExprNodes
.
DictNode
(
pos
,
key_value_pairs
=
keyword_args
)
return
arg_tuple
,
keyword_dict
def
p_call
(
s
,
function
):
...
...
@@ -474,12 +481,11 @@ def p_call(s, function):
args
=
positional_args
)
else
:
arg_tuple
,
keyword_dict
=
p_call_build_packed_args
(
pos
,
positional_args
,
keyword_args
,
star_arg
)
pos
,
positional_args
,
keyword_args
,
star_arg
,
starstar_arg
)
return
ExprNodes
.
GeneralCallNode
(
pos
,
function
=
function
,
positional_args
=
arg_tuple
,
keyword_args
=
keyword_dict
,
starstar_arg
=
starstar_arg
)
keyword_args
=
keyword_dict
)
#lambdef: 'lambda' [varargslist] ':' test
...
...
tests/run/non_dict_kwargs_T470.pyx
View file @
77cbab3a
...
...
@@ -40,7 +40,7 @@ def call_non_dict_test():
return
func
(
**
NonDict
())
def
call_non_dict_test_kw
():
return
func
(
a
=
5
,
**
NonDict
())
return
func
(
b
=
5
,
**
NonDict
())
class
SubDict
(
dict
):
...
...
@@ -51,4 +51,4 @@ def call_sub_dict_test():
return
func
(
**
SubDict
())
def
call_sub_dict_test_kw
():
return
func
(
a
=
5
,
**
SubDict
())
return
func
(
b
=
5
,
**
SubDict
())
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