Commit eb8e5c4d authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #764 from corona10/issue689

list recursive printing
parents 0fdbc574 87a906df
......@@ -67,6 +67,17 @@ extern "C" Box* listRepr(BoxedList* self) {
std::string O("");
llvm::raw_string_ostream os(O);
// Implementing Recursive Print of list in same way from Cpython
int recursive = Py_ReprEnter((PyObject*)self);
if (recursive != 0) {
if (recursive < 0)
return boxString(os.str());
os << "[...]";
return boxString(os.str());
}
os << '[';
for (int i = 0; i < self->size; i++) {
if (i > 0)
......@@ -79,6 +90,8 @@ extern "C" Box* listRepr(BoxedList* self) {
os << s->s();
}
os << ']';
Py_ReprLeave((PyObject*)self);
return boxString(os.str());
}
......
......@@ -15,6 +15,10 @@ l = range(7, -1, -2)
print sorted(l)
print l
l = range(5)
l[0] = l
print l
for i in xrange(-10, 10):
l2 = range(5)
l2.insert(i, 99)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment