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
904ca6e4
Commit
904ca6e4
authored
Aug 27, 2018
by
cjgibson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move introduction of CondExprNode prior to call to .analyse_types().
parent
03d00f3c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
43 deletions
+24
-43
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+24
-43
No files found.
Cython/Compiler/ExprNodes.py
View file @
904ca6e4
...
@@ -4749,9 +4749,29 @@ class SliceIndexNode(ExprNode):
...
@@ -4749,9 +4749,29 @@ class SliceIndexNode(ExprNode):
analyse_base
=
False
)
analyse_base
=
False
)
if
self
.
start
:
if
self
.
start
:
self
.
start
=
self
.
start
.
analyse_types
(
env
)
self
.
start
=
CondExprNode
(
self
.
start
.
pos
,
true_val
=
IntNode
(
self
.
start
.
pos
,
value
=
'0'
),
false_val
=
self
.
start
,
test
=
PrimaryCmpNode
(
self
.
start
.
pos
,
operand1
=
self
.
start
,
operator
=
'is'
,
operand2
=
NoneNode
(
self
.
start
.
pos
),
)
).
analyse_types
(
env
)
if
self
.
stop
:
if
self
.
stop
:
self
.
stop
=
self
.
stop
.
analyse_types
(
env
)
self
.
stop
=
CondExprNode
(
self
.
stop
.
pos
,
true_val
=
IntNode
(
self
.
stop
.
pos
,
value
=
'PY_SSIZE_T_MAX'
),
false_val
=
self
.
stop
,
test
=
PrimaryCmpNode
(
self
.
stop
.
pos
,
operand1
=
self
.
stop
,
operator
=
'is'
,
operand2
=
NoneNode
(
self
.
stop
.
pos
),
)
).
analyse_types
(
env
)
if
not
env
.
directives
[
'wraparound'
]:
if
not
env
.
directives
[
'wraparound'
]:
check_negative_indices
(
self
.
start
,
self
.
stop
)
check_negative_indices
(
self
.
start
,
self
.
stop
)
...
@@ -4794,50 +4814,11 @@ class SliceIndexNode(ExprNode):
...
@@ -4794,50 +4814,11 @@ class SliceIndexNode(ExprNode):
step
=
none_node
step
=
none_node
).
analyse_types
(
env
)
).
analyse_types
(
env
)
else
:
else
:
# @TODO: Issue-2508
# NameNode.coerce_to below returns an instance
# of CoerceFromPyTypeNode, which is attempting a hard coercion to
# PyrexTypes.c_py_ssize_t_type via __Pyx_PyIndex_AsSsize_t, which
# internally relies on the CPython builtin PyNumber_Index, which
# fails outright provided with non-integer input.
# As a result, the following code is generated:
# __pyx_t_TMPIDX = __Pyx_PyIndex_AsSsize_t(__pyx_v_VARNAME);
# Which, in the case of self.start, needs to become:
# if (__pyx_v_VARNAME == Py_None) { __pyx_t_TMPIDX = 0; } else { __pyx_t_TMPIDX = __Pyx_PyIndex_AsSsize_t(__pyx_v_VARNAME); }
# And, in the case of self.stop, needs to become:
# if (__pyx_v_VARNAME == Py_None) { __pyx_t_TMPIDX = PY_SSIZE_T_MAX; } else { __pyx_t_TMPIDX = __Pyx_PyIndex_AsSsize_t(__pyx_v_VARNAME); }
c_bool
=
PyrexTypes
.
c_bint_type
c_int
=
PyrexTypes
.
c_py_ssize_t_type
c_int
=
PyrexTypes
.
c_py_ssize_t_type
if
self
.
start
:
if
self
.
start
:
self
.
start
=
CondExprNode
(
self
.
start
=
self
.
start
.
coerce_to
(
c_int
,
env
)
self
.
start
.
pos
,
true_val
=
IntNode
(
self
.
start
.
pos
,
value
=
'0'
),
false_val
=
self
.
start
,
test
=
PrimaryCmpNode
(
self
.
start
.
pos
,
operand1
=
self
.
start
,
operator
=
'is'
,
operand2
=
NoneNode
(
self
.
start
.
pos
),
type
=
c_bool
,
# Why isn't this set automatically?
),
type
=
c_int
,
# Why isn't this set automatically?
is_temp
=
1
,
# Set to avoid call to calculate_result_code()
)
if
self
.
stop
:
if
self
.
stop
:
self
.
stop
=
CondExprNode
(
self
.
stop
=
self
.
stop
.
coerce_to
(
c_int
,
env
)
self
.
stop
.
pos
,
true_val
=
IntNode
(
self
.
stop
.
pos
,
value
=
'PY_SSIZE_T_MAX'
),
false_val
=
self
.
stop
,
test
=
PrimaryCmpNode
(
self
.
stop
.
pos
,
operand1
=
self
.
stop
,
operator
=
'is'
,
operand2
=
NoneNode
(
self
.
stop
.
pos
),
type
=
c_bool
,
# Why isn't this set automatically?
),
type
=
c_int
,
# Why isn't this set automatically?
is_temp
=
1
,
# Set to avoid call to calculate_result_code()
)
self
.
is_temp
=
1
self
.
is_temp
=
1
return
self
return
self
...
...
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