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
2491a3ee
Commit
2491a3ee
authored
Apr 23, 2011
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix locals()
parent
afe04a7f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
4 deletions
+12
-4
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+10
-2
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+2
-2
No files found.
Cython/Compiler/ExprNodes.py
View file @
2491a3ee
...
...
@@ -1269,6 +1269,7 @@ class NameNode(AtomicExprNode):
# type_entry Entry For extension type names, the original type entry
# cf_is_null boolean Is uninitialized before this node
# cf_maybe_null boolean Maybe uninitialized before this node
# allow_null boolean Don't raise UnboundLocalError
is_name
=
True
is_cython_module
=
False
...
...
@@ -1279,6 +1280,7 @@ class NameNode(AtomicExprNode):
type_entry
=
None
cf_maybe_null
=
True
cf_is_null
=
False
allow_null
=
False
def
create_analysed_rvalue
(
pos
,
env
,
entry
):
node
=
NameNode
(
pos
)
...
...
@@ -1556,7 +1558,7 @@ class NameNode(AtomicExprNode):
elif
entry
.
is_local
:
if
entry
.
type
.
is_pyobject
:
if
self
.
cf_maybe_null
or
self
.
cf_is
_null
:
if
(
self
.
cf_maybe_null
or
self
.
cf_is_null
)
and
not
self
.
allow
_null
:
code
.
putln
(
'if (%s == 0) { PyErr_SetString(PyExc_UnboundLocalError, "%s"); %s }'
%
(
entry
.
cname
,
entry
.
name
,
code
.
error_goto
(
self
.
pos
)))
...
...
@@ -4738,11 +4740,13 @@ class DictNode(ExprNode):
# Dictionary constructor.
#
# key_value_pairs [DictItemNode]
# exclude_null_values [boolean] Do not add NULL values to dict
#
# obj_conversion_errors [PyrexError] used internally
subexprs
=
[
'key_value_pairs'
]
is_temp
=
1
exclude_null_values
=
False
type
=
dict_type
obj_conversion_errors
=
[]
...
...
@@ -4830,11 +4834,15 @@ class DictNode(ExprNode):
for
item
in
self
.
key_value_pairs
:
item
.
generate_evaluation_code
(
code
)
if
self
.
type
.
is_pyobject
:
if
self
.
exclude_null_values
:
code
.
putln
(
'if (%s) {'
%
item
.
value
.
py_result
())
code
.
put_error_if_neg
(
self
.
pos
,
"PyDict_SetItem(%s, %s, %s)"
%
(
self
.
result
(),
item
.
key
.
py_result
(),
item
.
value
.
py_result
()))
if
self
.
exclude_null_values
:
code
.
putln
(
'}'
)
else
:
code
.
putln
(
"%s.%s = %s;"
%
(
self
.
result
(),
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
2491a3ee
...
...
@@ -2203,9 +2203,9 @@ class TransformBuiltinMethods(EnvTransform):
return
node
# nothing to do
items
=
[
ExprNodes
.
DictItemNode
(
pos
,
key
=
ExprNodes
.
StringNode
(
pos
,
value
=
var
),
value
=
ExprNodes
.
NameNode
(
pos
,
name
=
var
))
value
=
ExprNodes
.
NameNode
(
pos
,
name
=
var
,
allow_null
=
True
))
for
var
in
lenv
.
entries
]
return
ExprNodes
.
DictNode
(
pos
,
key_value_pairs
=
items
)
return
ExprNodes
.
DictNode
(
pos
,
key_value_pairs
=
items
,
exclude_null_values
=
True
)
else
:
# dir()
if
len
(
node
.
args
)
>
1
:
error
(
self
.
pos
,
"Builtin 'dir()' called with wrong number of args, expected 0-1, got %d"
...
...
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