Commit e14f792a authored by Kevin Modzelewski's avatar Kevin Modzelewski

Working on intmethods.py

parent ea7d3f0b
...@@ -1187,7 +1187,7 @@ Box* intLong(BoxedInt* self) { ...@@ -1187,7 +1187,7 @@ Box* intLong(BoxedInt* self) {
extern "C" Box* intIndex(BoxedInt* v) { extern "C" Box* intIndex(BoxedInt* v) {
if (PyInt_CheckExact(v)) if (PyInt_CheckExact(v))
return v; return incref(v);
return boxInt(v->n); return boxInt(v->n);
} }
...@@ -1237,10 +1237,10 @@ template <ExceptionStyle S> static Box* _intNew(Box* val, Box* _base) noexcept(S ...@@ -1237,10 +1237,10 @@ template <ExceptionStyle S> static Box* _intNew(Box* val, Box* _base) noexcept(S
if (PyString_Check(val)) { if (PyString_Check(val)) {
BoxedString* s = static_cast<BoxedString*>(val); BoxedString* s = static_cast<BoxedString*>(val);
AUTO_DECREF(s);
if (s->size() != strlen(s->data())) { if (s->size() != strlen(s->data())) {
Box* srepr = PyObject_Repr(val); Box* srepr = PyObject_Repr(val);
AUTO_DECREF(srepr);
if (S == CAPI) { if (S == CAPI) {
PyErr_Format(PyExc_ValueError, "invalid literal for int() with base %d: %s", base, PyErr_Format(PyExc_ValueError, "invalid literal for int() with base %d: %s", base,
PyString_AS_STRING(srepr)); PyString_AS_STRING(srepr));
...@@ -1300,8 +1300,6 @@ template <ExceptionStyle S> Box* intNew(Box* _cls, Box* val, Box* base) noexcept ...@@ -1300,8 +1300,6 @@ template <ExceptionStyle S> Box* intNew(Box* _cls, Box* val, Box* base) noexcept
return NULL; return NULL;
} }
AUTO_DECREF(n);
if (n->cls == long_cls) { if (n->cls == long_cls) {
if (cls == int_cls) if (cls == int_cls)
return n; return n;
...@@ -1312,6 +1310,8 @@ template <ExceptionStyle S> Box* intNew(Box* _cls, Box* val, Box* base) noexcept ...@@ -1312,6 +1310,8 @@ template <ExceptionStyle S> Box* intNew(Box* _cls, Box* val, Box* base) noexcept
} else } else
raiseExcHelper(OverflowError, "Python int too large to convert to C long"); raiseExcHelper(OverflowError, "Python int too large to convert to C long");
} }
AUTO_DECREF(n);
return new (cls) BoxedInt(n->n); return new (cls) BoxedInt(n->n);
} }
...@@ -1330,7 +1330,7 @@ static Box* intNewPacked(BoxedClass* type, Box* args, Box* kwds) noexcept { ...@@ -1330,7 +1330,7 @@ static Box* intNewPacked(BoxedClass* type, Box* args, Box* kwds) noexcept {
if (base == -909) if (base == -909)
return intNew<CAPI>(type, x, NULL); return intNew<CAPI>(type, x, NULL);
else else
return intNew<CAPI>(type, x, boxInt(base)); return intNew<CAPI>(type, x, autoDecref(boxInt(base)));
} }
static const unsigned char BitLengthTable[32] static const unsigned char BitLengthTable[32]
......
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