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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
cdb895f6
Commit
cdb895f6
authored
Aug 30, 2011
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix lambda's default args, ticket #723
parent
155664e8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
4 deletions
+29
-4
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+13
-3
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+4
-1
tests/run/lambda_T723.pyx
tests/run/lambda_T723.pyx
+12
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
cdb895f6
...
...
@@ -5258,10 +5258,20 @@ class LambdaNode(InnerFunctionNode):
name
=
StringEncoding
.
EncodedString
(
'<lambda>'
)
def
analyse_declarations
(
self
,
env
):
self
.
def_node
.
no_assignment_synthesis
=
True
self
.
def_node
.
pymethdef_required
=
True
self
.
def_node
.
analyse_declarations
(
env
)
self
.
pymethdef_cname
=
self
.
def_node
.
entry
.
pymethdef_cname
env
.
add_lambda_def
(
self
.
def_node
)
def
analyse_types
(
self
,
env
):
self
.
def_node
.
analyse_expressions
(
env
)
super
(
LambdaNode
,
self
).
analyse_types
(
env
)
def
generate_result_code
(
self
,
code
):
self
.
def_node
.
generate_execution_code
(
code
)
super
(
LambdaNode
,
self
).
generate_result_code
(
code
)
class
GeneratorExpressionNode
(
LambdaNode
):
# A generator expression, e.g. (i for i in range(10))
...
...
@@ -5275,11 +5285,11 @@ class GeneratorExpressionNode(LambdaNode):
binding
=
False
def
analyse_declarations
(
self
,
env
):
self
.
def_node
.
no_assignment_synthesis
=
True
self
.
def_node
.
analyse_declarations
(
env
)
super
(
GeneratorExpressionNode
,
self
).
analyse_declarations
(
env
)
# No pymethdef required
self
.
def_node
.
pymethdef_required
=
False
# Force genexpr signature
self
.
def_node
.
entry
.
signature
=
TypeSlots
.
pyfunction_noargs
env
.
add_lambda_def
(
self
.
def_node
)
def
generate_result_code
(
self
,
code
):
code
.
putln
(
...
...
Cython/Compiler/Nodes.py
View file @
cdb895f6
...
...
@@ -1162,6 +1162,7 @@ class FuncDefNode(StatNode, BlockNode):
# entry Symtab.Entry
# needs_closure boolean Whether or not this function has inner functions/classes/yield
# needs_outer_scope boolean Whether or not this function requires outer scope
# pymethdef_required boolean Force Python method struct generation
# directive_locals { string : NameNode } locals defined by cython.locals(...)
# star_arg PyArgDeclNode or None * argument
# starstar_arg PyArgDeclNode or None ** argument
...
...
@@ -1170,6 +1171,7 @@ class FuncDefNode(StatNode, BlockNode):
assmt
=
None
needs_closure
=
False
needs_outer_scope
=
False
pymethdef_required
=
False
is_generator
=
False
is_generator_body
=
False
modifiers
=
[]
...
...
@@ -1289,7 +1291,8 @@ class FuncDefNode(StatNode, BlockNode):
if
preprocessor_guard
:
code
.
putln
(
preprocessor_guard
)
with_pymethdef
=
self
.
needs_assignment_synthesis
(
env
,
code
)
with_pymethdef
=
(
self
.
needs_assignment_synthesis
(
env
,
code
)
or
self
.
pymethdef_required
)
if
self
.
py_func
:
self
.
py_func
.
generate_function_header
(
code
,
with_pymethdef
=
with_pymethdef
,
...
...
tests/run/lambda_T723.pyx
0 → 100644
View file @
cdb895f6
# mode: run
# ticket: 723
# tags: lambda
def
t723
(
a
):
"""
>>> t723(2)()
4
>>> t723(2)(3)
9
"""
return
lambda
x
=
a
:
x
*
x
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