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
b21fad57
Commit
b21fad57
authored
Jun 11, 2016
by
Marius Wachtler
Committed by
GitHub
Jun 11, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1246 from aisk/test_list
make more list unit test pass
parents
eb8815b4
4f48bbe9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
2 deletions
+49
-2
src/runtime/list.cpp
src/runtime/list.cpp
+13
-1
test/tests/list.py
test/tests/list.py
+36
-1
No files found.
src/runtime/list.cpp
View file @
b21fad57
...
...
@@ -727,6 +727,11 @@ Box* listMul(BoxedList* self, Box* rhs) {
return
incref
(
NotImplemented
);
}
if
(
n
>
0
&&
Py_SIZE
(
self
)
>
PY_SSIZE_T_MAX
/
n
)
{
PyErr_NoMemory
();
throwCAPIException
();
}
int
s
=
self
->
size
;
BoxedList
*
rtn
=
new
BoxedList
();
...
...
@@ -755,6 +760,11 @@ Box* listImul(BoxedList* self, Box* rhs) {
return
incref
(
NotImplemented
);
}
if
(
n
>
0
&&
Py_SIZE
(
self
)
>
PY_SSIZE_T_MAX
/
n
)
{
PyErr_NoMemory
();
throwCAPIException
();
}
int
s
=
self
->
size
;
self
->
ensure
(
n
*
s
);
...
...
@@ -1129,7 +1139,7 @@ Box* listIndex(BoxedList* self, Box* elt, Box* _start, Box** args) {
}
stop
=
std
::
min
(
stop
,
self
->
size
);
for
(
int64_t
i
=
start
;
i
<
stop
;
i
++
)
{
for
(
int64_t
i
=
start
;
i
<
stop
&&
i
<
self
->
size
;
i
++
)
{
Box
*
e
=
self
->
elts
->
elts
[
i
];
int
r
=
PyObject_RichCompareBool
(
e
,
elt
,
Py_EQ
);
...
...
@@ -1171,6 +1181,8 @@ BoxedClass* list_reverse_iterator_cls = NULL;
Box
*
listInit
(
BoxedList
*
self
,
Box
*
container
)
{
assert
(
PyList_Check
(
self
));
BoxedList
::
clear
(
self
);
if
(
container
)
{
Box
*
r
=
listIAdd
(
self
,
container
);
Py_DECREF
(
r
);
...
...
test/tests/list.py
View file @
b21fad57
import
sys
l
=
range
(
5
)
print
l
print
l
*
5
...
...
@@ -68,7 +70,7 @@ for i in xrange(1, 6):
print
list_index
.
index
(
i
,
-
1
,
-
1
)
except
ValueError
as
e
:
print
e
assert
list_index
.
index
(
3
)
==
2
assert
[
1
,
'2'
].
index
(
'2'
)
==
1
...
...
@@ -244,3 +246,36 @@ try:
print
range
(
5
).
index
(
10
,
100
,
200
)
except
Exception
as
e
:
print
e
lst
=
[
4
,
5
,
6
,
7
]
n
=
int
((
sys
.
maxsize
*
2
+
2
)
//
len
(
lst
))
try
:
lst
*
n
except
MemoryError
as
e
:
print
e
else
:
raise
RuntimeError
(
'MemoryError not raised'
)
try
:
lst
*=
n
except
MemoryError
as
e
:
print
e
l
=
[
1
,
2
,
3
]
l
.
__init__
()
print
l
class
EvilCmp
:
def
__init__
(
self
,
victim
):
self
.
victim
=
victim
def
__eq__
(
self
,
other
):
del
self
.
victim
[:]
return
False
a
=
[]
a
[:]
=
[
EvilCmp
(
a
)
for
_
in
xrange
(
100
)]
try
:
a
.
index
(
None
)
except
ValueError
as
e
:
print
e
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