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
d88716c7
Commit
d88716c7
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
00d29b76
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 @
d88716c7
...
@@ -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 @
d88716c7
...
@@ -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