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
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
Hide 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,7 +947,18 @@ class BoolNode(ConstNode):
return
self
.
value
def
calculate_result_code
(
self
):
return
str
(
int
(
self
.
value
))
if
self
.
type
.
is_pyobject
:
return
self
.
value
and
'Py_True'
or
'Py_False'
else
:
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
):
...
...
tests/run/constant_folding.py
View file @
d832f463
...
...
@@ -27,6 +27,7 @@ def unop_floats():
@
cython
.
test_fail_if_path_exists
(
"//UnaryMinusNode"
,
"//UnaryPlusNode"
,
"//CoerceToPyTypeNode"
,
)
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