Skip to content

Commit 951e0a1

Browse files
committed
return to non-macro style
1 parent 5b6d626 commit 951e0a1

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

Objects/exceptions.c

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,21 +1865,23 @@ ImportError_reduce(PyObject *self, PyObject *Py_UNUSED(ignored))
18651865
}
18661866

18671867
static PyObject *
1868-
ImportError_repr(PyImportErrorObject *self)
1868+
ImportError_repr(PyObject *self)
18691869
{
18701870
int hasargs = PyTuple_GET_SIZE(((PyBaseExceptionObject *)self)->args) != 0;
1871-
PyObject *r = BaseException_repr((PyObject *)self);
1872-
if (r && (self->name || self->path)) {
1871+
PyObject *r = BaseException_repr(self);
1872+
PyImportErrorObject *exc = PyImportErrorObject_CAST(self);
1873+
1874+
if (r && (exc->name || exc->path)) {
18731875
/* remove ')' */
18741876
Py_SETREF(r, PyUnicode_Substring(r, 0, PyUnicode_GET_LENGTH(r) - 1));
1875-
if (r && self->name) {
1877+
if (r && exc->name) {
18761878
Py_SETREF(r, PyUnicode_FromFormat("%U%sname=%R",
1877-
r, hasargs ? ", " : "", self->name));
1879+
r, hasargs ? ", " : "", exc->name));
18781880
hasargs = 1;
18791881
}
1880-
if (r && self->path) {
1882+
if (r && exc->path) {
18811883
Py_SETREF(r, PyUnicode_FromFormat("%U%spath=%R",
1882-
r, hasargs ? ", " : "", self->path));
1884+
r, hasargs ? ", " : "", exc->path));
18831885
}
18841886
if (r) {
18851887
Py_SETREF(r, PyUnicode_FromFormat("%U)", r));
@@ -1905,12 +1907,23 @@ static PyMethodDef ImportError_methods[] = {
19051907
{NULL}
19061908
};
19071909

1908-
ComplexExtendsException(PyExc_Exception, ImportError,
1909-
ImportError, 0 /* new */,
1910-
ImportError_methods, ImportError_members,
1911-
0 /* getset */, ImportError_str,
1912-
"Import can't find module, or can't find name in "
1913-
"module.");
1910+
static PyTypeObject _PyExc_ImportError = {
1911+
PyVarObject_HEAD_INIT(NULL, 0)
1912+
"ImportError",
1913+
sizeof(PyImportErrorObject), 0,
1914+
(destructor)ImportError_dealloc, 0, 0, 0, 0,
1915+
ImportError_repr, 0, 0, 0, 0, 0,
1916+
ImportError_str, 0, 0, 0,
1917+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
1918+
PyDoc_STR("Import can't find module, or can't find name in "
1919+
"module."),
1920+
(traverseproc)ImportError_traverse,
1921+
(inquiry)ImportError_clear, 0, 0, 0, 0, ImportError_methods,
1922+
ImportError_members, 0, &_PyExc_Exception,
1923+
0, 0, 0, offsetof(PyImportErrorObject, dict),
1924+
(initproc)ImportError_init,
1925+
};
1926+
PyObject *PyExc_ImportError = (PyObject *)&_PyExc_ImportError;
19141927

19151928
/*
19161929
* ModuleNotFoundError extends ImportError

0 commit comments

Comments
 (0)