diff options
Diffstat (limited to 'Objects/exceptions.c')
-rw-r--r-- | Objects/exceptions.c | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c index a401806..2d096a7 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -41,7 +41,7 @@ BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds) static int BaseException_init(PyBaseExceptionObject *self, PyObject *args, PyObject *kwds) { - if (!_PyArg_NoKeywords(self->ob_type->tp_name, kwds)) + if (!_PyArg_NoKeywords(Py_Type(self)->tp_name, kwds)) return -1; Py_DECREF(self->args); @@ -64,7 +64,7 @@ BaseException_dealloc(PyBaseExceptionObject *self) { _PyObject_GC_UNTRACK(self); BaseException_clear(self); - self->ob_type->tp_free((PyObject *)self); + Py_Type(self)->tp_free((PyObject *)self); } static int @@ -94,7 +94,7 @@ BaseException_repr(PyBaseExceptionObject *self) char *name; char *dot; - name = (char *)self->ob_type->tp_name; + name = (char *)Py_Type(self)->tp_name; dot = strrchr(name, '.'); if (dot != NULL) name = dot+1; @@ -106,9 +106,9 @@ static PyObject * BaseException_reduce(PyBaseExceptionObject *self) { if (self->args && self->dict) - return PyTuple_Pack(3, self->ob_type, self->args, self->dict); + return PyTuple_Pack(3, Py_Type(self), self->args, self->dict); else - return PyTuple_Pack(2, self->ob_type, self->args); + return PyTuple_Pack(2, Py_Type(self), self->args); } /* @@ -207,8 +207,7 @@ static PyGetSetDef BaseException_getset[] = { static PyTypeObject _PyExc_BaseException = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "BaseException", /*tp_name*/ sizeof(PyBaseExceptionObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -258,8 +257,7 @@ PyObject *PyExc_BaseException = (PyObject *)&_PyExc_BaseException; */ #define SimpleExtendsException(EXCBASE, EXCNAME, EXCDOC) \ static PyTypeObject _PyExc_ ## EXCNAME = { \ - PyObject_HEAD_INIT(NULL) \ - 0, \ + PyVarObject_HEAD_INIT(NULL, 0) \ # EXCNAME, \ sizeof(PyBaseExceptionObject), \ 0, (destructor)BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, \ @@ -274,8 +272,7 @@ PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME #define MiddlingExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDOC) \ static PyTypeObject _PyExc_ ## EXCNAME = { \ - PyObject_HEAD_INIT(NULL) \ - 0, \ + PyVarObject_HEAD_INIT(NULL, 0) \ # EXCNAME, \ sizeof(Py ## EXCSTORE ## Object), \ 0, (destructor)EXCSTORE ## _dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ @@ -290,8 +287,7 @@ PyObject *PyExc_ ## EXCNAME = (PyObject *)&_PyExc_ ## EXCNAME #define ComplexExtendsException(EXCBASE, EXCNAME, EXCSTORE, EXCDEALLOC, EXCMETHODS, EXCMEMBERS, EXCSTR, EXCDOC) \ static PyTypeObject _PyExc_ ## EXCNAME = { \ - PyObject_HEAD_INIT(NULL) \ - 0, \ + PyVarObject_HEAD_INIT(NULL, 0) \ # EXCNAME, \ sizeof(Py ## EXCSTORE ## Object), 0, \ (destructor)EXCSTORE ## _dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ @@ -369,7 +365,7 @@ SystemExit_dealloc(PySystemExitObject *self) { _PyObject_GC_UNTRACK(self); SystemExit_clear(self); - self->ob_type->tp_free((PyObject *)self); + Py_Type(self)->tp_free((PyObject *)self); } static int @@ -474,7 +470,7 @@ EnvironmentError_dealloc(PyEnvironmentErrorObject *self) { _PyObject_GC_UNTRACK(self); EnvironmentError_clear(self); - self->ob_type->tp_free((PyObject *)self); + Py_Type(self)->tp_free((PyObject *)self); } static int @@ -540,9 +536,9 @@ EnvironmentError_reduce(PyEnvironmentErrorObject *self) Py_INCREF(args); if (self->dict) - res = PyTuple_Pack(3, self->ob_type, args, self->dict); + res = PyTuple_Pack(3, Py_Type(self), args, self->dict); else - res = PyTuple_Pack(2, self->ob_type, args); + res = PyTuple_Pack(2, Py_Type(self), args); Py_DECREF(args); return res; } @@ -595,7 +591,7 @@ WindowsError_dealloc(PyWindowsErrorObject *self) { _PyObject_GC_UNTRACK(self); WindowsError_clear(self); - self->ob_type->tp_free((PyObject *)self); + Py_Type(self)->tp_free((PyObject *)self); } static int @@ -793,7 +789,7 @@ SyntaxError_dealloc(PySyntaxErrorObject *self) { _PyObject_GC_UNTRACK(self); SyntaxError_clear(self); - self->ob_type->tp_free((PyObject *)self); + Py_Type(self)->tp_free((PyObject *)self); } static int @@ -1244,7 +1240,7 @@ UnicodeError_dealloc(PyUnicodeErrorObject *self) { _PyObject_GC_UNTRACK(self); UnicodeError_clear(self); - self->ob_type->tp_free((PyObject *)self); + Py_Type(self)->tp_free((PyObject *)self); } static int @@ -1316,8 +1312,7 @@ UnicodeEncodeError_str(PyObject *self) } static PyTypeObject _PyExc_UnicodeEncodeError = { - PyObject_HEAD_INIT(NULL) - 0, + PyVarObject_HEAD_INIT(NULL, 0) "UnicodeEncodeError", sizeof(PyUnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1378,8 +1373,7 @@ UnicodeDecodeError_str(PyObject *self) } static PyTypeObject _PyExc_UnicodeDecodeError = { - PyObject_HEAD_INIT(NULL) - 0, + PyVarObject_HEAD_INIT(NULL, 0) "UnicodeDecodeError", sizeof(PyUnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1465,8 +1459,7 @@ UnicodeTranslateError_str(PyObject *self) } static PyTypeObject _PyExc_UnicodeTranslateError = { - PyObject_HEAD_INIT(NULL) - 0, + PyVarObject_HEAD_INIT(NULL, 0) "UnicodeTranslateError", sizeof(PyUnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |