find_module_path_list() fails if _Py_fopen() failed and raised an exception
(UnicodeEncodeError).
diff --git a/Python/import.c b/Python/import.c
index 9ec8cd8..de5dc0c 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -1908,6 +1908,10 @@
             fp = _Py_fopen(filename, filemode);
             if (fp == NULL) {
                 Py_DECREF(filename);
+                if (PyErr_Occurred()) {
+                    Py_DECREF(prefix);
+                    return NULL;
+                }
                 continue;
             }
             match = case_ok(filename, -(Py_ssize_t)strlen(fdp->suffix), name);