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
bd50b09a
Commit
bd50b09a
authored
Apr 24, 2012
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove dict items that can't be represented as PyObject after type inference
parent
33e78f15
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
4 deletions
+29
-4
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+20
-4
tests/run/locals.pyx
tests/run/locals.pyx
+9
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
bd50b09a
...
...
@@ -6724,17 +6724,33 @@ class GlobalsExprNode(AtomicExprNode):
code
.
put_gotref
(
self
.
result
())
class
LocalsDictItemNode
(
DictItemNode
):
def
analyse_types
(
self
,
env
):
self
.
key
.
analyse_types
(
env
)
self
.
value
.
analyse_types
(
env
)
self
.
key
=
self
.
key
.
coerce_to_pyobject
(
env
)
if
self
.
value
.
type
.
can_coerce_to_pyobject
(
env
):
self
.
value
=
self
.
value
.
coerce_to_pyobject
(
env
)
else
:
self
.
value
=
None
class
FuncLocalsExprNode
(
DictNode
):
def
__init__
(
self
,
pos
,
env
):
local_vars
=
[
entry
.
name
for
entry
in
env
.
entries
.
values
()
if
entry
.
name
and
(
entry
.
type
is
unspecified_type
or
entry
.
type
.
can_coerce_to_pyobject
(
env
))]
items
=
[
DictItemNode
(
pos
,
key
=
IdentifierStringNode
(
pos
,
value
=
var
),
value
=
NameNode
(
pos
,
name
=
var
,
allow_null
=
True
))
if
entry
.
name
]
items
=
[
LocalsDictItemNode
(
pos
,
key
=
IdentifierStringNode
(
pos
,
value
=
var
),
value
=
NameNode
(
pos
,
name
=
var
,
allow_null
=
True
))
for
var
in
local_vars
]
DictNode
.
__init__
(
self
,
pos
,
key_value_pairs
=
items
,
exclude_null_values
=
True
)
def
analyse_types
(
self
,
env
):
super
(
FuncLocalsExprNode
,
self
).
analyse_types
(
env
)
self
.
key_value_pairs
=
[
i
for
i
in
self
.
key_value_pairs
if
i
.
value
is
not
None
]
class
PyClassLocalsExprNode
(
AtomicExprNode
):
def
__init__
(
self
,
pos
,
pyclass_dict
):
...
...
tests/run/locals.pyx
View file @
bd50b09a
...
...
@@ -79,3 +79,12 @@ def locals_ctype():
"""
cdef
int
*
p
=
NULL
return
'p'
in
locals
()
def
locals_ctype_inferred
():
"""
>>> locals_ctype_inferred()
False
"""
cdef
int
*
p
=
NULL
b
=
p
return
'b'
in
locals
()
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