summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS3
-rw-r--r--Python/import.c7
2 files changed, 6 insertions, 4 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index e102404..047f272 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1?
Core and Builtins
-----------------
+- Issue #14084: Fix a file descriptor leak when importing a module with a
+ bad encoding.
+
- Upgrade Unicode data to Unicode 6.1.
- Issue #14040: Remove rarely used file name suffixes for C extensions
diff --git a/Python/import.c b/Python/import.c
index 8bd7a61..4871b99 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -3628,11 +3628,9 @@ call_find_module(PyObject *name, PyObject *path_list)
if (fd != -1)
fd = dup(fd);
fclose(fp);
- if (fd == -1) {
- PyErr_SetFromErrno(PyExc_OSError);
- return NULL;
- }
fp = NULL;
+ if (fd == -1)
+ return PyErr_SetFromErrno(PyExc_OSError);
}
if (fd != -1) {
if (strchr(fdp->mode, 'b') == NULL) {
@@ -3642,6 +3640,7 @@ call_find_module(PyObject *name, PyObject *path_list)
lseek(fd, 0, 0); /* Reset position */
if (found_encoding == NULL && PyErr_Occurred()) {
Py_XDECREF(pathobj);
+ close(fd);
return NULL;
}
encoding = (found_encoding != NULL) ? found_encoding :