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
dafd5e0e
Commit
dafd5e0e
authored
Apr 25, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix function declarations inside of 'with' blocks
parent
8445af77
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+4
-0
tests/run/withstat_py.py
tests/run/withstat_py.py
+20
-0
No files found.
Cython/Compiler/Nodes.py
View file @
dafd5e0e
...
@@ -4870,6 +4870,10 @@ class WithStatNode(StatNode):
...
@@ -4870,6 +4870,10 @@ class WithStatNode(StatNode):
self
.
manager
.
analyse_types
(
env
)
self
.
manager
.
analyse_types
(
env
)
self
.
body
.
analyse_expressions
(
env
)
self
.
body
.
analyse_expressions
(
env
)
def
generate_function_definitions
(
self
,
env
,
code
):
self
.
manager
.
generate_function_definitions
(
env
,
code
)
self
.
body
.
generate_function_definitions
(
env
,
code
)
def
generate_execution_code
(
self
,
code
):
def
generate_execution_code
(
self
,
code
):
code
.
putln
(
"/*with:*/ {"
)
code
.
putln
(
"/*with:*/ {"
)
self
.
manager
.
generate_evaluation_code
(
code
)
self
.
manager
.
generate_evaluation_code
(
code
)
...
...
tests/run/withstat_py.py
View file @
dafd5e0e
...
@@ -113,6 +113,26 @@ def with_exception(exit_ret):
...
@@ -113,6 +113,26 @@ def with_exception(exit_ret):
except
:
except
:
print
(
"outer except"
)
print
(
"outer except"
)
def
functions_in_with
():
"""
>>> f = functions_in_with()
enter
exit <type 'type'> <type 'MyException'> <type 'traceback'>
outer except
>>> f(1)[0]
1
>>> print(f(1)[1])
value
"""
try
:
with
ContextManager
(
"value"
)
as
value
:
def
f
(
x
):
return
x
,
value
make
=
lambda
x
:
x
()
raise
make
(
MyException
)
except
:
print
(
"outer except"
)
return
f
def
multitarget
():
def
multitarget
():
"""
"""
>>> multitarget()
>>> multitarget()
...
...
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