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
Gwenaël Samain
cython
Commits
426999c6
Commit
426999c6
authored
Nov 27, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix temp handling in 'with' transform
parent
571e3b08
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+9
-7
Cython/Compiler/Tests/TestParseTreeTransforms.py
Cython/Compiler/Tests/TestParseTreeTransforms.py
+2
-0
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
426999c6
...
@@ -457,6 +457,7 @@ class WithTransform(CythonTransform):
...
@@ -457,6 +457,7 @@ class WithTransform(CythonTransform):
EXIT = MGR.__exit__
EXIT = MGR.__exit__
MGR.__enter__()
MGR.__enter__()
EXC = True
EXC = True
EXCINFO = None
try:
try:
try:
try:
BODY
BODY
...
@@ -475,6 +476,7 @@ class WithTransform(CythonTransform):
...
@@ -475,6 +476,7 @@ class WithTransform(CythonTransform):
EXIT = MGR.__exit__
EXIT = MGR.__exit__
VALUE = MGR.__enter__()
VALUE = MGR.__enter__()
EXC = True
EXC = True
EXCINFO = None
try:
try:
try:
try:
TARGET = VALUE
TARGET = VALUE
...
@@ -490,7 +492,9 @@ class WithTransform(CythonTransform):
...
@@ -490,7 +492,9 @@ class WithTransform(CythonTransform):
pipeline
=
[
NormalizeTree
(
None
)])
pipeline
=
[
NormalizeTree
(
None
)])
def
visit_WithStatNode
(
self
,
node
):
def
visit_WithStatNode
(
self
,
node
):
excinfo_temp
=
TempHandle
(
PyrexTypes
.
py_object_type
)
# FIXME: excinfo_temp should be more local to the except
# clause that uses it, to avoid the presetting to None
excinfo_temp
=
TempHandle
(
Builtin
.
tuple_type
)
if
node
.
target
is
not
None
:
if
node
.
target
is
not
None
:
result
=
self
.
template_with_target
.
substitute
({
result
=
self
.
template_with_target
.
substitute
({
u'EXPR'
:
node
.
manager
,
u'EXPR'
:
node
.
manager
,
...
@@ -498,17 +502,15 @@ class WithTransform(CythonTransform):
...
@@ -498,17 +502,15 @@ class WithTransform(CythonTransform):
u'TARGET'
:
node
.
target
,
u'TARGET'
:
node
.
target
,
u'EXCINFO'
:
excinfo_temp
.
ref
(
node
.
pos
)
u'EXCINFO'
:
excinfo_temp
.
ref
(
node
.
pos
)
},
pos
=
node
.
pos
)
},
pos
=
node
.
pos
)
# Set except excinfo target to EXCINFO
result
.
body
.
stats
[
4
].
body
.
stats
[
0
].
except_clauses
[
0
].
excinfo_target
=
(
excinfo_temp
.
ref
(
node
.
pos
))
else
:
else
:
result
=
self
.
template_without_target
.
substitute
({
result
=
self
.
template_without_target
.
substitute
({
u'EXPR'
:
node
.
manager
,
u'EXPR'
:
node
.
manager
,
u'BODY'
:
node
.
body
,
u'BODY'
:
node
.
body
,
u'EXCINFO'
:
excinfo_temp
.
ref
(
node
.
pos
)
u'EXCINFO'
:
excinfo_temp
.
ref
(
node
.
pos
)
},
pos
=
node
.
pos
)
},
pos
=
node
.
pos
)
# Set except excinfo target to EXCINFO
# Set except excinfo target to EXCINFO
result
.
body
.
stats
[
4
].
body
.
stats
[
0
].
except_clauses
[
0
].
excinfo_target
=
(
result
.
body
.
stats
[
5
].
body
.
stats
[
0
].
except_clauses
[
0
].
excinfo_target
=
(
excinfo_temp
.
ref
(
node
.
pos
))
excinfo_temp
.
ref
(
node
.
pos
))
return
TempsBlockNode
(
node
.
pos
,
temps
=
[
excinfo_temp
],
body
=
result
)
return
TempsBlockNode
(
node
.
pos
,
temps
=
[
excinfo_temp
],
body
=
result
)
...
...
Cython/Compiler/Tests/TestParseTreeTransforms.py
View file @
426999c6
...
@@ -99,6 +99,7 @@ class TestWithTransform(TransformTest):
...
@@ -99,6 +99,7 @@ class TestWithTransform(TransformTest):
$1_2 = $1_0.__exit__
$1_2 = $1_0.__exit__
$1_0.__enter__()
$1_0.__enter__()
$1_1 = True
$1_1 = True
$0_0 = None
try:
try:
try:
try:
y = z ** 3
y = z ** 3
...
@@ -123,6 +124,7 @@ class TestWithTransform(TransformTest):
...
@@ -123,6 +124,7 @@ class TestWithTransform(TransformTest):
$1_2 = $1_0.__exit__
$1_2 = $1_0.__exit__
$1_3 = $1_0.__enter__()
$1_3 = $1_0.__enter__()
$1_1 = True
$1_1 = True
$0_0 = None
try:
try:
try:
try:
y = $1_3
y = $1_3
...
...
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