[Python-checkins] cpython: find_module_path_list() fails if _Py_fopen() failed and raised an exception

victor.stinner python-checkins at python.org
Mon Jun 20 15:01:07 CEST 2011


http://hg.python.org/cpython/rev/7731d2ab4fd4
changeset:   70900:7731d2ab4fd4
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Mon Jun 20 15:01:10 2011 +0200
summary:
  find_module_path_list() fails if _Py_fopen() failed and raised an exception
(UnicodeEncodeError).

files:
  Python/import.c |  4 ++++
  1 files changed, 4 insertions(+), 0 deletions(-)


diff --git a/Python/import.c b/Python/import.c
--- 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);

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list