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
c147fe6d
Commit
c147fe6d
authored
Apr 23, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix 'with' statement at module scope by reactivating old temp code for it
parent
771071fd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
17 deletions
+29
-17
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+1
-1
Cython/Compiler/TreeFragment.py
Cython/Compiler/TreeFragment.py
+7
-9
tests/bugs.txt
tests/bugs.txt
+0
-1
tests/run/with_statement_module_level_T536.pyx
tests/run/with_statement_module_level_T536.pyx
+21
-6
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
c147fe6d
...
...
@@ -958,7 +958,7 @@ class WithTransform(CythonTransform, SkipDeclarations):
},
pos
=
node
.
pos
)
# Set except excinfo target to EXCINFO
try_except
=
result
.
stats
[
-
1
].
body
.
stats
[
-
1
]
try_except
=
result
.
body
.
stats
[
-
1
].
body
.
stats
[
-
1
]
try_except
.
except_clauses
[
0
].
excinfo_target
=
exc_info
return
result
...
...
Cython/Compiler/TreeFragment.py
View file @
c147fe6d
...
...
@@ -121,16 +121,15 @@ class TemplateTransform(VisitorTransform):
temphandles
=
[]
for
temp
in
temps
:
TemplateTransform
.
temp_name_counter
+=
1
handle
=
"__tmpvar_%d"
%
TemplateTransform
.
temp_name_counter
# handle = UtilNodes.TempHandle(PyrexTypes.py_object_type)
handle
=
UtilNodes
.
TempHandle
(
PyrexTypes
.
py_object_type
)
tempmap
[
temp
]
=
handle
#
temphandles.append(handle)
temphandles
.
append
(
handle
)
self
.
tempmap
=
tempmap
result
=
super
(
TemplateTransform
,
self
).
__call__
(
node
)
#
if temps:
#
result = UtilNodes.TempsBlockNode(self.get_pos(node),
#
temps=temphandles,
#
body=result)
if
temps
:
result
=
UtilNodes
.
TempsBlockNode
(
self
.
get_pos
(
node
),
temps
=
temphandles
,
body
=
result
)
return
result
def
get_pos
(
self
,
node
):
...
...
@@ -161,9 +160,8 @@ class TemplateTransform(VisitorTransform):
def
visit_NameNode
(
self
,
node
):
temphandle
=
self
.
tempmap
.
get
(
node
.
name
)
if
temphandle
:
return
NameNode
(
pos
=
node
.
pos
,
name
=
temphandle
)
# Replace name with temporary
#
return temphandle.ref(self.get_pos(node))
return
temphandle
.
ref
(
self
.
get_pos
(
node
))
else
:
return
self
.
try_substitution
(
node
,
node
.
name
)
...
...
tests/bugs.txt
View file @
c147fe6d
...
...
@@ -10,7 +10,6 @@ cfunc_call_tuple_args_T408
compile.cpp_operators
cpp_templated_ctypedef
cpp_structs
with_statement_module_level_T536
function_as_method_T494
closure_inside_cdef_T554
pure_mode_cmethod_inheritance_T583
...
...
tests/run/with_statement_module_level_T536.pyx
View file @
c147fe6d
...
...
@@ -3,17 +3,32 @@
__doc__
=
"""
>>> inner_result
['ENTER']
>>> result
>>> result # doctest: +ELLIPSIS
['ENTER', "EXIT (<type 'exceptions.ValueError'>, ValueError('TEST',), <traceback object at ...)"]
>>> inner_result_no_exc
['ENTER']
>>> result_no_exc
['ENTER', 'EXIT (None, None, None)']
"""
result
=
[]
class
ContextManager
(
object
):
def
__init__
(
self
,
result
):
self
.
result
=
result
def
__enter__
(
self
):
result
.
append
(
"ENTER"
)
self
.
result
.
append
(
"ENTER"
)
def
__exit__
(
self
,
*
values
):
result
.
append
(
"EXIT %r"
%
(
values
,))
self
.
result
.
append
(
"EXIT %r"
%
(
values
,))
return
True
result_no_exc
=
[]
with
ContextManager
(
result_no_exc
)
as
c
:
inner_result_no_exc
=
result_no_exc
[:]
result
=
[]
with
ContextManager
()
as
c
:
with
ContextManager
(
result
)
as
c
:
inner_result
=
result
[:]
raise
ValueError
(
'TEST'
)
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