Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
8e45b42d
Commit
8e45b42d
authored
Aug 13, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #833 from undingen/generators2
support yield statements inside lambdas
parents
93243be1
7ebe9720
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
3 deletions
+9
-3
src/capi/abstract.cpp
src/capi/abstract.cpp
+1
-1
src/codegen/codegen.cpp
src/codegen/codegen.cpp
+1
-1
src/core/cfg.cpp
src/core/cfg.cpp
+1
-1
test/tests/generators.py
test/tests/generators.py
+6
-0
No files found.
src/capi/abstract.cpp
View file @
8e45b42d
...
@@ -1650,7 +1650,7 @@ extern "C" int PyNumber_Check(PyObject* obj) noexcept {
...
@@ -1650,7 +1650,7 @@ extern "C" int PyNumber_Check(PyObject* obj) noexcept {
assert
(
obj
&&
obj
->
cls
);
assert
(
obj
&&
obj
->
cls
);
// Our check, since we don't currently fill in tp_as_number:
// Our check, since we don't currently fill in tp_as_number:
if
(
Py
Float_Check
(
obj
)
||
PyFloat
_Check
(
obj
)
||
PyFloat_Check
(
obj
))
if
(
Py
Int_Check
(
obj
)
||
PyLong
_Check
(
obj
)
||
PyFloat_Check
(
obj
))
return
true
;
return
true
;
// The CPython check:
// The CPython check:
...
...
src/codegen/codegen.cpp
View file @
8e45b42d
...
@@ -73,13 +73,13 @@ SourceInfo::SourceInfo(BoxedModule* m, ScopingAnalysis* scoping, FutureFlags fut
...
@@ -73,13 +73,13 @@ SourceInfo::SourceInfo(BoxedModule* m, ScopingAnalysis* scoping, FutureFlags fut
switch
(
ast
->
type
)
{
switch
(
ast
->
type
)
{
case
AST_TYPE
:
:
ClassDef
:
case
AST_TYPE
:
:
ClassDef
:
case
AST_TYPE
:
:
Lambda
:
case
AST_TYPE
:
:
Module
:
case
AST_TYPE
:
:
Module
:
case
AST_TYPE
:
:
Expression
:
case
AST_TYPE
:
:
Expression
:
case
AST_TYPE
:
:
Suite
:
case
AST_TYPE
:
:
Suite
:
is_generator
=
false
;
is_generator
=
false
;
break
;
break
;
case
AST_TYPE
:
:
FunctionDef
:
case
AST_TYPE
:
:
FunctionDef
:
case
AST_TYPE
:
:
Lambda
:
is_generator
=
containsYield
(
ast
);
is_generator
=
containsYield
(
ast
);
break
;
break
;
default:
default:
...
...
src/core/cfg.cpp
View file @
8e45b42d
...
@@ -1178,7 +1178,7 @@ private:
...
@@ -1178,7 +1178,7 @@ private:
push_back
(
makeExpr
(
new
AST_LangPrimitive
(
AST_LangPrimitive
::
UNCACHE_EXC_INFO
)));
push_back
(
makeExpr
(
new
AST_LangPrimitive
(
AST_LangPrimitive
::
UNCACHE_EXC_INFO
)));
if
(
root_type
!=
AST_TYPE
::
FunctionDef
)
if
(
root_type
!=
AST_TYPE
::
FunctionDef
&&
root_type
!=
AST_TYPE
::
Lambda
)
raiseExcHelper
(
SyntaxError
,
"'yield' outside function"
);
raiseExcHelper
(
SyntaxError
,
"'yield' outside function"
);
return
makeLoad
(
node_name
,
node
);
return
makeLoad
(
node_name
,
node
);
...
...
test/tests/generators.py
View file @
8e45b42d
...
@@ -128,3 +128,9 @@ try:
...
@@ -128,3 +128,9 @@ try:
g
.
next
()
g
.
next
()
except
Exception
as
e
:
except
Exception
as
e
:
print
type
(
e
),
e
# StopIteration
print
type
(
e
),
e
# StopIteration
x
=
lambda
:
(
yield
1
)
print
list
(
x
())
x
=
lambda
:
((
yield
1
),
(
yield
2
))
print
list
(
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