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
ef007829
Commit
ef007829
authored
Jul 11, 2016
by
Kevin Modzelewski
Committed by
GitHub
Jul 11, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1287 from sizeoftank/work_tp_as_mapping_issue1197
Add missing tp_as_mapping
parents
37fa8a96
6a6d74fc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
1 deletion
+30
-1
src/runtime/list.cpp
src/runtime/list.cpp
+24
-1
src/runtime/str.cpp
src/runtime/str.cpp
+3
-0
src/runtime/tuple.cpp
src/runtime/tuple.cpp
+3
-0
No files found.
src/runtime/list.cpp
View file @
ef007829
...
...
@@ -397,7 +397,9 @@ int list_ass_ext_slice(BoxedList* self, PyObject* item, PyObject* value) {
return
-
1
;
}
RELEASE_ASSERT
(
step
!=
1
,
"should have handled this elsewhere"
);
if
(
step
==
1
)
{
return
list_ass_slice
((
PyListObject
*
)
self
,
start
,
stop
,
value
);
}
/* Make sure s[5:2] = [..] inserts at the right place:
before 5, not before 2. */
...
...
@@ -517,6 +519,23 @@ int list_ass_ext_slice(BoxedList* self, PyObject* item, PyObject* value) {
}
}
int
list_ass_subscript
(
BoxedList
*
self
,
PyObject
*
slice
,
PyObject
*
value
)
{
assert
(
PyList_Check
(
self
));
if
(
PyIndex_Check
(
slice
))
{
Py_ssize_t
i
=
PyNumber_AsSsize_t
(
slice
,
PyExc_IndexError
);
if
(
i
==
-
1
&&
PyErr_Occurred
())
return
-
1
;
if
(
i
<
0
)
i
+=
PyList_GET_SIZE
(
self
);
return
list_ass_item
((
PyListObject
*
)
self
,
i
,
value
);
}
else
if
(
slice
->
cls
==
slice_cls
)
{
return
list_ass_ext_slice
(
self
,
slice
,
value
);
}
else
{
PyErr_Format
(
PyExc_TypeError
,
"list indices must be integers, not %.200s"
,
slice
->
cls
->
tp_name
);
return
-
1
;
}
}
static
inline
void
listSetitemSliceInt64
(
BoxedList
*
self
,
i64
start
,
i64
stop
,
i64
step
,
Box
*
v
)
{
RELEASE_ASSERT
(
step
==
1
,
"step sizes must be 1 in this code path"
);
...
...
@@ -1533,6 +1552,10 @@ void setupList() {
list_iterator_cls
->
tp_iternext
=
listiter_next
;
list_iterator_cls
->
tp_iter
=
PyObject_SelfIter
;
list_cls
->
tp_as_mapping
->
mp_length
=
(
lenfunc
)
list_length
;
list_cls
->
tp_as_mapping
->
mp_subscript
=
(
binaryfunc
)
listGetitem
<
CAPI
>
;
list_cls
->
tp_as_mapping
->
mp_ass_subscript
=
(
objobjargproc
)
list_ass_subscript
;
list_reverse_iterator_cls
->
giveAttr
(
"__name__"
,
boxString
(
"listreverseiterator"
));
hasnext
=
FunctionMetadata
::
create
((
void
*
)
listreviterHasnextUnboxed
,
BOOL
,
1
);
...
...
src/runtime/str.cpp
View file @
ef007829
...
...
@@ -2987,6 +2987,9 @@ void setupStr() {
str_cls
->
tp_as_sequence
->
sq_repeat
=
(
ssizeargfunc
)
string_repeat
;
str_cls
->
tp_as_sequence
->
sq_slice
=
str_slice
;
str_cls
->
tp_as_mapping
->
mp_length
=
(
lenfunc
)
str_length
;
str_cls
->
tp_as_mapping
->
mp_subscript
=
(
binaryfunc
)
strGetitem
<
CAPI
>
;
str_cls
->
tp_new
=
(
newfunc
)
strNewPacked
;
basestring_cls
->
giveAttr
(
"__doc__"
,
...
...
src/runtime/tuple.cpp
View file @
ef007829
...
...
@@ -811,6 +811,9 @@ void setupTuple() {
tuple_cls
->
tp_as_sequence
->
sq_contains
=
(
objobjproc
)
tuplecontains
;
tuple_cls
->
tp_iter
=
tupleIter
;
tuple_cls
->
tp_as_mapping
->
mp_length
=
(
lenfunc
)
tuplelength
;
tuple_cls
->
tp_as_mapping
->
mp_subscript
=
(
binaryfunc
)
tupleGetitem
<
CAPI
>
;
FunctionMetadata
*
hasnext
=
FunctionMetadata
::
create
((
void
*
)
tupleiterHasnextUnboxed
,
BOOL
,
1
);
hasnext
->
addVersion
((
void
*
)
tupleiterHasnext
,
BOXED_BOOL
);
tuple_iterator_cls
->
giveAttr
(
"__hasnext__"
,
new
BoxedFunction
(
hasnext
));
...
...
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