Commit a38d319c authored by Kevin Modzelewski's avatar Kevin Modzelewski

Fix a bunch of 'return self' that were missing increfs

parent f665e516
...@@ -1351,7 +1351,7 @@ public: ...@@ -1351,7 +1351,7 @@ public:
static Box* iter(Box* _self) noexcept { static Box* iter(Box* _self) noexcept {
assert(_self->cls == enumerate_cls); assert(_self->cls == enumerate_cls);
BoxedEnumerate* self = static_cast<BoxedEnumerate*>(_self); BoxedEnumerate* self = static_cast<BoxedEnumerate*>(_self);
return self; return incref(self);
} }
static Box* next(Box* _self) { static Box* next(Box* _self) {
......
...@@ -1036,7 +1036,7 @@ extern "C" Box* floatFloat(BoxedFloat* self) { ...@@ -1036,7 +1036,7 @@ extern "C" Box* floatFloat(BoxedFloat* self) {
getTypeName(self)); getTypeName(self));
if (self->cls == float_cls) if (self->cls == float_cls)
return self; return incref(self);
return boxFloat(self->d); return boxFloat(self->d);
} }
......
...@@ -185,8 +185,7 @@ Box* xrange(Box* cls, Box* start, Box* stop, Box** args) { ...@@ -185,8 +185,7 @@ Box* xrange(Box* cls, Box* start, Box* stop, Box** args) {
Box* xrangeIterIter(Box* self) { Box* xrangeIterIter(Box* self) {
assert(self->cls == xrange_iterator_cls); assert(self->cls == xrange_iterator_cls);
Py_INCREF(self); return incref(self);
return self;
} }
Box* xrangeIter(Box* self) noexcept { Box* xrangeIter(Box* self) noexcept {
......
...@@ -1083,7 +1083,7 @@ extern "C" Box* intHash(BoxedInt* self) { ...@@ -1083,7 +1083,7 @@ extern "C" Box* intHash(BoxedInt* self) {
return boxInt(-2); return boxInt(-2);
if (self->cls == int_cls) if (self->cls == int_cls)
return self; return incref(self);
return boxInt(self->n); return boxInt(self->n);
} }
...@@ -1155,7 +1155,7 @@ extern "C" Box* intTrunc(BoxedInt* self) { ...@@ -1155,7 +1155,7 @@ extern "C" Box* intTrunc(BoxedInt* self) {
getTypeName(self)); getTypeName(self));
if (self->cls == int_cls) if (self->cls == int_cls)
return self; return incref(self);
return boxInt(self->n); return boxInt(self->n);
} }
...@@ -1165,7 +1165,7 @@ extern "C" Box* intInt(BoxedInt* self) { ...@@ -1165,7 +1165,7 @@ extern "C" Box* intInt(BoxedInt* self) {
getTypeName(self)); getTypeName(self));
if (self->cls == int_cls) if (self->cls == int_cls)
return self; return incref(self);
return boxInt(self->n); return boxInt(self->n);
} }
......
...@@ -784,8 +784,7 @@ Box* listIAdd(BoxedList* self, Box* _rhs) { ...@@ -784,8 +784,7 @@ Box* listIAdd(BoxedList* self, Box* _rhs) {
int s2 = rhs->size; int s2 = rhs->size;
if (s2 == 0) { if (s2 == 0) {
Py_INCREF(self); return incref(self);
return self;
} }
self->ensure(s1 + s2); self->ensure(s1 + s2);
...@@ -796,8 +795,7 @@ Box* listIAdd(BoxedList* self, Box* _rhs) { ...@@ -796,8 +795,7 @@ Box* listIAdd(BoxedList* self, Box* _rhs) {
Py_INCREF(self->elts->elts[i + s1]); Py_INCREF(self->elts->elts[i + s1]);
} }
Py_INCREF(self); return incref(self);
return self;
} }
if (_rhs->cls == tuple_cls) { if (_rhs->cls == tuple_cls) {
...@@ -807,8 +805,7 @@ Box* listIAdd(BoxedList* self, Box* _rhs) { ...@@ -807,8 +805,7 @@ Box* listIAdd(BoxedList* self, Box* _rhs) {
int s2 = rhs->ob_size; int s2 = rhs->ob_size;
if (s2 == 0) { if (s2 == 0) {
Py_INCREF(self); return incref(self);
return self;
} }
self->ensure(s1 + s2); self->ensure(s1 + s2);
...@@ -819,8 +816,7 @@ Box* listIAdd(BoxedList* self, Box* _rhs) { ...@@ -819,8 +816,7 @@ Box* listIAdd(BoxedList* self, Box* _rhs) {
Py_INCREF(self->elts->elts[i + s1]); Py_INCREF(self->elts->elts[i + s1]);
} }
Py_INCREF(self); return incref(self);
return self;
} }
RELEASE_ASSERT(_rhs != self, "unsupported"); RELEASE_ASSERT(_rhs != self, "unsupported");
...@@ -828,8 +824,7 @@ Box* listIAdd(BoxedList* self, Box* _rhs) { ...@@ -828,8 +824,7 @@ Box* listIAdd(BoxedList* self, Box* _rhs) {
for (auto* b : _rhs->pyElements()) for (auto* b : _rhs->pyElements())
listAppendInternalStolen(self, b); listAppendInternalStolen(self, b);
Py_INCREF(self); return incref(self);
return self;
} }
Box* listExtend(BoxedList* self, Box* _rhs) { Box* listExtend(BoxedList* self, Box* _rhs) {
......
...@@ -1577,7 +1577,7 @@ extern "C" Box* longTrunc(BoxedLong* self) { ...@@ -1577,7 +1577,7 @@ extern "C" Box* longTrunc(BoxedLong* self) {
raiseExcHelper(TypeError, "descriptor '__trunc__' requires a 'long' object but received a '%s'", raiseExcHelper(TypeError, "descriptor '__trunc__' requires a 'long' object but received a '%s'",
getTypeName(self)); getTypeName(self));
return self; return incref(self);
} }
extern "C" Box* longIndex(BoxedLong* v) noexcept { extern "C" Box* longIndex(BoxedLong* v) noexcept {
......
...@@ -183,7 +183,7 @@ Box* tupleMulInt(BoxedTuple* self, int n) { ...@@ -183,7 +183,7 @@ Box* tupleMulInt(BoxedTuple* self, int n) {
n = 0; n = 0;
if ((s == 0 || n == 1) && PyTuple_CheckExact(self)) { if ((s == 0 || n == 1) && PyTuple_CheckExact(self)) {
return self; return incref(self);
} else { } else {
BoxedTuple* rtn = BoxedTuple::create(n * s); BoxedTuple* rtn = BoxedTuple::create(n * s);
int rtn_i = 0; int rtn_i = 0;
......
# expected: reffail
import math import math
def type_trunc(type, arg): def type_trunc(type, arg):
......
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