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
bc297512
Commit
bc297512
authored
Apr 18, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix T284, cdef list setitem
parent
8cc95d98
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
9 deletions
+17
-9
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+7
-8
tests/bugs.txt
tests/bugs.txt
+0
-1
tests/run/cdef_setitem_T284.pyx
tests/run/cdef_setitem_T284.pyx
+10
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
bc297512
...
@@ -1856,14 +1856,13 @@ class IndexNode(ExprNode):
...
@@ -1856,14 +1856,13 @@ class IndexNode(ExprNode):
index_code
=
self
.
index
.
py_result
()
index_code
=
self
.
index
.
py_result
()
if
self
.
base
.
type
is
dict_type
:
if
self
.
base
.
type
is
dict_type
:
function
=
"PyDict_SetItem"
function
=
"PyDict_SetItem"
elif
self
.
base
.
type
is
list_type
:
# It would seem that we could specalized lists/tuples, but that
function
=
"PyList_SetItem"
# shouldn't happen here.
# don't use PyTuple_SetItem(), as we'd normally get a
# Both PyList_SetItem PyTuple_SetItem and a Py_ssize_t as input,
# TypeError when changing a tuple, while PyTuple_SetItem()
# not a PyObject*, and bad conversion here would give the wrong
# would allow updates
# exception. Also, tuples are supposed to be immutable, and raise
#
# TypeErrors when trying to set their entries (PyTuple_SetItem
#elif self.base.type is tuple_type:
# is for creating new tuples from).
# function = "PyTuple_SetItem"
else
:
else
:
function
=
"PyObject_SetItem"
function
=
"PyObject_SetItem"
code
.
putln
(
code
.
putln
(
...
...
tests/bugs.txt
View file @
bc297512
...
@@ -14,4 +14,3 @@ large_consts_T237
...
@@ -14,4 +14,3 @@ large_consts_T237
bad_c_struct_T252
bad_c_struct_T252
missing_baseclass_in_predecl_T262
missing_baseclass_in_predecl_T262
ifelseexpr_T267
ifelseexpr_T267
cdef_setitem_T284
tests/run/cdef_setitem_T284.pyx
View file @
bc297512
__doc__
=
u'''
__doc__
=
u'''
>>> no_cdef()
>>> no_cdef()
>>> with_cdef()
>>> with_cdef()
>>> test_list(range(11), -2, None)
[0, 1, 2, 3, 4, 5, 6, 7, 8, None, 10]
>>> test_list(range(11), "invalid index", None)
Traceback (most recent call last):
...
TypeError: list indices must be integers
'''
'''
def
no_cdef
():
def
no_cdef
():
lst
=
range
(
11
)
lst
=
range
(
11
)
...
@@ -15,3 +21,7 @@ def with_cdef():
...
@@ -15,3 +21,7 @@ def with_cdef():
lst
[
ob
]
=
-
10
lst
[
ob
]
=
-
10
cdef
dict
dd
=
{}
cdef
dict
dd
=
{}
dd
[
ob
]
=
-
10
dd
[
ob
]
=
-
10
def
test_list
(
list
L
,
object
i
,
object
a
):
L
[
i
]
=
a
return
L
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