Mercurial > cpython-lru_cache-weakref
diff Python/errors.c @ 84444:e3ec8b176a80
Issue #15767: Revert 3a50025f1900 for ModuleNotFoundError
| author | Brett Cannon <brett@python.org> |
|---|---|
| date | Thu, 04 Jul 2013 17:48:16 -0400 |
| parents | 3a50025f1900 |
| children | 2f7c4df5cc46 |
line wrap: on
line diff
--- a/Python/errors.c Thu Jul 04 17:44:08 2013 -0400 +++ b/Python/errors.c Thu Jul 04 17:48:16 2013 -0400 @@ -619,25 +619,12 @@ #endif /* MS_WINDOWS */ PyObject * -PyErr_SetImportErrorSubclass(PyObject *exception, PyObject *msg, - PyObject *name, PyObject *path) +PyErr_SetImportError(PyObject *msg, PyObject *name, PyObject *path) { - int issubclass; PyObject *args, *kwargs, *error; - issubclass = PyObject_IsSubclass(exception, PyExc_ImportError); - if (issubclass < 0) { - return NULL; - } - else if (!issubclass) { - PyErr_SetString(PyExc_TypeError, "expected a subclass of ImportError"); + if (msg == NULL) return NULL; - } - - if (msg == NULL) { - PyErr_SetString(PyExc_TypeError, "expected a message argument"); - return NULL; - } args = PyTuple_New(1); if (args == NULL) @@ -662,7 +649,7 @@ PyDict_SetItemString(kwargs, "name", name); PyDict_SetItemString(kwargs, "path", path); - error = PyObject_Call(exception, args, kwargs); + error = PyObject_Call(PyExc_ImportError, args, kwargs); if (error != NULL) { PyErr_SetObject((PyObject *)Py_TYPE(error), error); Py_DECREF(error); @@ -674,12 +661,6 @@ return NULL; } -PyObject * -PyErr_SetImportError(PyObject *msg, PyObject *name, PyObject *path) -{ - return PyErr_SetImportErrorSubclass(PyExc_ImportError, msg, name, path); -} - void _PyErr_BadInternalCall(const char *filename, int lineno) {
