Commit b528ca09 authored by Kevin Modzelewski's avatar Kevin Modzelewski

gets farther

parent b9ed25a8
...@@ -756,6 +756,9 @@ Box* listIAdd(BoxedList* self, Box* _rhs) { ...@@ -756,6 +756,9 @@ Box* listIAdd(BoxedList* self, Box* _rhs) {
memcpy(self->elts->elts + s1, rhs->elts->elts, sizeof(rhs->elts->elts[0]) * s2); memcpy(self->elts->elts + s1, rhs->elts->elts, sizeof(rhs->elts->elts[0]) * s2);
self->size = s1 + s2; self->size = s1 + s2;
for (int i = 0; i < s2; i++) {
Py_INCREF(self->elts->elts[i + s1]);
}
Py_INCREF(self); Py_INCREF(self);
return self; return self;
...@@ -774,6 +777,9 @@ Box* listIAdd(BoxedList* self, Box* _rhs) { ...@@ -774,6 +777,9 @@ Box* listIAdd(BoxedList* self, Box* _rhs) {
memcpy(self->elts->elts + s1, rhs->elts, sizeof(self->elts->elts[0]) * s2); memcpy(self->elts->elts + s1, rhs->elts, sizeof(self->elts->elts[0]) * s2);
self->size = s1 + s2; self->size = s1 + s2;
for (int i = 0; i < s2; i++) {
Py_INCREF(self->elts->elts[i + s1]);
}
Py_INCREF(self); Py_INCREF(self);
return self; return self;
...@@ -1099,14 +1105,10 @@ extern "C" PyObject* PyList_New(Py_ssize_t size) noexcept { ...@@ -1099,14 +1105,10 @@ extern "C" PyObject* PyList_New(Py_ssize_t size) noexcept {
try { try {
BoxedList* l = new BoxedList(); BoxedList* l = new BoxedList();
if (size) { if (size) {
// This function is supposed to return a list of `size` NULL elements.
// That will probably trip an assert somewhere if we try to create that (ex
// I think the GC will expect them to be real objects so they can be relocated),
// so put None in instead
l->ensure(size); l->ensure(size);
for (Py_ssize_t i = 0; i < size; i++) { for (Py_ssize_t i = 0; i < size; i++) {
l->elts->elts[i] = None; l->elts->elts[i] = NULL;
} }
l->size = size; l->size = size;
} }
...@@ -1222,7 +1224,9 @@ extern "C" PyObject* _PyList_Extend(PyListObject* self, PyObject* b) noexcept { ...@@ -1222,7 +1224,9 @@ extern "C" PyObject* _PyList_Extend(PyListObject* self, PyObject* b) noexcept {
assert(PyList_Check(l)); assert(PyList_Check(l));
try { try {
return listIAdd(l, b); Box* r = listIAdd(l, b);
Py_DECREF(r);
Py_RETURN_NONE;
} catch (ExcInfo e) { } catch (ExcInfo e) {
setCAPIException(e); setCAPIException(e);
return NULL; return NULL;
......
...@@ -3693,14 +3693,14 @@ void BoxedList::dealloc(Box* b) noexcept { ...@@ -3693,14 +3693,14 @@ void BoxedList::dealloc(Box* b) noexcept {
while (--i >= 0) { while (--i >= 0) {
Py_XDECREF(op->elts->elts[i]); Py_XDECREF(op->elts->elts[i]);
} }
PyMem_FREE(op->elts); //PyMem_FREE(op->elts);
} }
#if 0 #if 0
if (numfree < PyList_MAXFREELIST && PyList_CheckExact(op)) if (numfree < PyList_MAXFREELIST && PyList_CheckExact(op))
free_list[numfree++] = op; free_list[numfree++] = op;
else else
#endif #endif
Py_TYPE(op)->tp_free((PyObject *)op); Py_TYPE(op)->tp_free((PyObject*)op);
Py_TRASHCAN_SAFE_END(op) Py_TRASHCAN_SAFE_END(op)
} }
......
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