|
|
@@ -275,11 +275,7 @@ result(PyObject *self, PyObject *timeout) const {
|
|
|
static PyObject *exc_type = nullptr;
|
|
|
if (exc_type == nullptr) {
|
|
|
// Get the TimeoutError that asyncio uses, too.
|
|
|
-#if PY_VERSION_HEX >= 0x03080000
|
|
|
PyObject *module = PyImport_ImportModule("asyncio.exceptions");
|
|
|
-#else
|
|
|
- PyObject *module = PyImport_ImportModule("concurrent.futures._base");
|
|
|
-#endif
|
|
|
if (module != nullptr) {
|
|
|
exc_type = PyObject_GetAttrString(module, "TimeoutError");
|
|
|
Py_DECREF(module);
|
|
|
@@ -289,15 +285,9 @@ result(PyObject *self, PyObject *timeout) const {
|
|
|
}
|
|
|
// If we can't get that, we should pretend and make our own.
|
|
|
if (exc_type == nullptr) {
|
|
|
-#if PY_VERSION_HEX >= 0x03080000
|
|
|
exc_type = PyErr_NewExceptionWithDoc((char*)"asyncio.exceptions.TimeoutError",
|
|
|
(char*)"The operation exceeded the given deadline.",
|
|
|
nullptr, nullptr);
|
|
|
-#else
|
|
|
- exc_type = PyErr_NewExceptionWithDoc((char*)"concurrent.futures._base.TimeoutError",
|
|
|
- (char*)"The operation exceeded the given deadline.",
|
|
|
- nullptr, nullptr);
|
|
|
-#endif
|
|
|
}
|
|
|
}
|
|
|
PyErr_SetNone(exc_type);
|
|
|
@@ -403,11 +393,7 @@ get_cancelled_error_type() {
|
|
|
PyErr_Fetch(&curexc_type, &curexc_value, &curexc_traceback);
|
|
|
|
|
|
// Get the CancelledError that asyncio uses, too.
|
|
|
-#if PY_VERSION_HEX >= 0x03080000
|
|
|
PyObject *module = PyImport_ImportModule("asyncio.exceptions");
|
|
|
-#else
|
|
|
- PyObject *module = PyImport_ImportModule("concurrent.futures._base");
|
|
|
-#endif
|
|
|
if (module != nullptr) {
|
|
|
exc_type = PyObject_GetAttrString(module, "CancelledError");
|
|
|
Py_DECREF(module);
|
|
|
@@ -415,15 +401,9 @@ get_cancelled_error_type() {
|
|
|
|
|
|
// If we can't get that, we should pretend and make our own.
|
|
|
if (exc_type == nullptr) {
|
|
|
-#if PY_VERSION_HEX >= 0x03080000
|
|
|
exc_type = PyErr_NewExceptionWithDoc((char *)"asyncio.exceptions.CancelledError",
|
|
|
(char *)"The Future or Task was cancelled.",
|
|
|
PyExc_BaseException, nullptr);
|
|
|
-#else
|
|
|
- exc_type = PyErr_NewExceptionWithDoc((char *)"concurrent.futures._base.CancelledError",
|
|
|
- (char *)"The Future was cancelled.",
|
|
|
- nullptr, nullptr);
|
|
|
-#endif
|
|
|
}
|
|
|
|
|
|
PyErr_Restore(curexc_type, curexc_value, curexc_traceback);
|