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
d832f463
Commit
d832f463
authored
Nov 24, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use plain constants for Python bool values instead of coerced C ints
parent
1d98bd20
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+12
-1
tests/run/constant_folding.py
tests/run/constant_folding.py
+1
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
d832f463
...
@@ -947,8 +947,19 @@ class BoolNode(ConstNode):
...
@@ -947,8 +947,19 @@ class BoolNode(ConstNode):
return
self
.
value
return
self
.
value
def
calculate_result_code
(
self
):
def
calculate_result_code
(
self
):
if
self
.
type
.
is_pyobject
:
return
self
.
value
and
'Py_True'
or
'Py_False'
else
:
return
str
(
int
(
self
.
value
))
return
str
(
int
(
self
.
value
))
def
coerce_to
(
self
,
dst_type
,
env
):
if
dst_type
.
is_pyobject
and
self
.
type
.
is_int
:
return
BoolNode
(
self
.
pos
,
value
=
self
.
value
,
constant_result
=
self
.
constant_result
,
type
=
Builtin
.
bool_type
)
return
ConstNode
.
coerce_to
(
self
,
dst_type
,
env
)
class
NullNode
(
ConstNode
):
class
NullNode
(
ConstNode
):
type
=
PyrexTypes
.
c_null_ptr_type
type
=
PyrexTypes
.
c_null_ptr_type
...
...
tests/run/constant_folding.py
View file @
d832f463
...
@@ -27,6 +27,7 @@ def unop_floats():
...
@@ -27,6 +27,7 @@ def unop_floats():
@
cython
.
test_fail_if_path_exists
(
@
cython
.
test_fail_if_path_exists
(
"//UnaryMinusNode"
,
"//UnaryMinusNode"
,
"//UnaryPlusNode"
,
"//UnaryPlusNode"
,
"//CoerceToPyTypeNode"
,
)
)
def
unop_py_floats_tuple
():
def
unop_py_floats_tuple
():
"""
"""
...
...
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