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
263b0091
Commit
263b0091
authored
Oct 14, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix type inference for target of with statement
parent
cee1011c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
Cython/Compiler/TypeInference.py
Cython/Compiler/TypeInference.py
+5
-0
tests/run/type_inference.pyx
tests/run/type_inference.pyx
+18
-0
No files found.
Cython/Compiler/TypeInference.py
View file @
263b0091
...
...
@@ -65,6 +65,11 @@ class MarkAssignments(CythonTransform):
# Could use this info to infer cdef class attributes...
pass
def
visit_WithTargetAssignmentStatNode
(
self
,
node
):
self
.
mark_assignment
(
node
.
lhs
,
node
.
rhs
)
self
.
visitchildren
(
node
)
return
node
def
visit_SingleAssignmentNode
(
self
,
node
):
self
.
mark_assignment
(
node
.
lhs
,
node
.
rhs
)
self
.
visitchildren
(
node
)
...
...
tests/run/type_inference.pyx
View file @
263b0091
...
...
@@ -529,6 +529,24 @@ def large_literals():
assert
typeof
(
d
)
==
"Python object"
,
typeof
(
d
)
class
EmptyContextManager
(
object
):
def
__enter__
(
self
):
return
None
def
__exit__
(
self
,
*
args
):
return
0
def
with_statement
():
"""
>>> with_statement()
Python object
'Python object'
"""
x
=
1.0
with
EmptyContextManager
()
as
x
:
print
(
typeof
(
x
))
return
typeof
(
x
)
# Regression test for trac #638.
def
bar
(
foo
):
...
...
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