Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
5bacdd4b
Commit
5bacdd4b
authored
Sep 08, 2015
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add PySequence_SetItem and GetItem
parent
c66b6f17
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
9 deletions
+46
-9
src/capi/abstract.cpp
src/capi/abstract.cpp
+43
-9
test/tests/operator_test.py
test/tests/operator_test.py
+3
-0
No files found.
src/capi/abstract.cpp
View file @
5bacdd4b
...
@@ -1606,20 +1606,54 @@ extern "C" PyObject* PySequence_GetSlice(PyObject* s, Py_ssize_t i1, Py_ssize_t
...
@@ -1606,20 +1606,54 @@ extern "C" PyObject* PySequence_GetSlice(PyObject* s, Py_ssize_t i1, Py_ssize_t
return
type_error
(
"'%.200s' object is unsliceable"
,
s
);
return
type_error
(
"'%.200s' object is unsliceable"
,
s
);
}
}
extern
"C"
int
PySequence_SetItem
(
PyObject
*
o
,
Py_ssize_t
i
,
PyObject
*
v
)
noexcept
{
extern
"C"
int
PySequence_SetItem
(
PyObject
*
s
,
Py_ssize_t
i
,
PyObject
*
o
)
noexcept
{
fatalOrError
(
PyExc_NotImplementedError
,
"unimplemented"
);
PySequenceMethods
*
m
;
if
(
s
==
NULL
)
{
null_error
();
return
-
1
;
}
m
=
s
->
cls
->
tp_as_sequence
;
if
(
m
&&
m
->
sq_ass_item
)
{
if
(
i
<
0
)
{
if
(
m
->
sq_length
)
{
Py_ssize_t
l
=
(
*
m
->
sq_length
)(
s
);
if
(
l
<
0
)
return
-
1
;
i
+=
l
;
}
}
return
m
->
sq_ass_item
(
s
,
i
,
o
);
}
type_error
(
"'%.200s' object does not support item assignment"
,
s
);
return
-
1
;
return
-
1
;
}
}
extern
"C"
int
PySequence_DelItem
(
PyObject
*
o
,
Py_ssize_t
i
)
noexcept
{
extern
"C"
int
PySequence_DelItem
(
PyObject
*
s
,
Py_ssize_t
i
)
noexcept
{
try
{
PySequenceMethods
*
m
;
// Not sure if this is really the same:
delitem
(
o
,
boxInt
(
i
));
if
(
s
==
NULL
)
{
return
0
;
null_error
();
}
catch
(
ExcInfo
e
)
{
setCAPIException
(
e
);
return
-
1
;
return
-
1
;
}
}
m
=
s
->
cls
->
tp_as_sequence
;
if
(
m
&&
m
->
sq_ass_item
)
{
if
(
i
<
0
)
{
if
(
m
->
sq_length
)
{
Py_ssize_t
l
=
(
*
m
->
sq_length
)(
s
);
if
(
l
<
0
)
return
-
1
;
i
+=
l
;
}
}
return
m
->
sq_ass_item
(
s
,
i
,
(
PyObject
*
)
NULL
);
}
type_error
(
"'%.200s' object doesn't support item deletion"
,
s
);
return
-
1
;
}
}
extern
"C"
int
PySequence_SetSlice
(
PyObject
*
s
,
Py_ssize_t
i1
,
Py_ssize_t
i2
,
PyObject
*
o
)
noexcept
{
extern
"C"
int
PySequence_SetSlice
(
PyObject
*
s
,
Py_ssize_t
i1
,
Py_ssize_t
i2
,
PyObject
*
o
)
noexcept
{
...
...
test/tests/operator_test.py
View file @
5bacdd4b
...
@@ -20,3 +20,6 @@ for op in sorted(dir(operator)):
...
@@ -20,3 +20,6 @@ for op in sorted(dir(operator)):
if
op
.
startswith
(
"_"
):
if
op
.
startswith
(
"_"
):
continue
continue
print
getattr
(
operator
,
op
).
__name__
print
getattr
(
operator
,
op
).
__name__
a
=
range
(
4
)
operator
.
setitem
(
a
,
1
,
3
)
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