Commit 298c835c authored by Kevin Modzelewski's avatar Kevin Modzelewski

Fix a couple CAPI-only bugs

parent 3b9ca8a5
...@@ -37,6 +37,7 @@ BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds) ...@@ -37,6 +37,7 @@ BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (!self) if (!self)
return NULL; return NULL;
self->message = NULL; self->message = NULL;
// Pyston change:
PyObject_InitHcAttrs(&self->hcattrs); PyObject_InitHcAttrs(&self->hcattrs);
self->args = PyTuple_New(0); self->args = PyTuple_New(0);
...@@ -72,6 +73,7 @@ BaseException_init(PyBaseExceptionObject *self, PyObject *args, PyObject *kwds) ...@@ -72,6 +73,7 @@ BaseException_init(PyBaseExceptionObject *self, PyObject *args, PyObject *kwds)
return 0; return 0;
} }
// Pyston addition:
PyObject* PyErr_CreateExceptionInstance(PyObject* _type, PyObject* arg) { PyObject* PyErr_CreateExceptionInstance(PyObject* _type, PyObject* arg) {
if (PyType_Check(_type) && ((PyTypeObject*)_type)->tp_new == (newfunc)BaseException_new && if (PyType_Check(_type) && ((PyTypeObject*)_type)->tp_new == (newfunc)BaseException_new &&
((PyTypeObject*)_type)->tp_init == (initproc)BaseException_init) { ((PyTypeObject*)_type)->tp_init == (initproc)BaseException_init) {
...@@ -91,6 +93,7 @@ PyObject* PyErr_CreateExceptionInstance(PyObject* _type, PyObject* arg) { ...@@ -91,6 +93,7 @@ PyObject* PyErr_CreateExceptionInstance(PyObject* _type, PyObject* arg) {
Py_DECREF(self); Py_DECREF(self);
return NULL; return NULL;
} }
Py_INCREF(arg);
self->message = arg; self->message = arg;
} else { } else {
self->args = PyTuple_New(0); self->args = PyTuple_New(0);
......
...@@ -1247,6 +1247,7 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo ...@@ -1247,6 +1247,7 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
PyErr_Format(TypeError, "__init__() should return None, not '%s'", getTypeName(autoDecref(initrtn))); PyErr_Format(TypeError, "__init__() should return None, not '%s'", getTypeName(autoDecref(initrtn)));
return NULL; return NULL;
} }
Py_DECREF(initrtn);
} else } else
made = assertInitNone(initrtn, made); // assertInitNone is optimized for the rewriter case; this call made = assertInitNone(initrtn, made); // assertInitNone is optimized for the rewriter case; this call
// here could be improved if it is an issue. // here could be improved if it is an issue.
......
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