Kaydet (Commit) cf1c8339 authored tarafından Antoine Pitrou's avatar Antoine Pitrou

Issue #14084: Fix a file descriptor leak when importing a module with a bad encoding.

...@@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1? ...@@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1?
Core and Builtins 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. - Upgrade Unicode data to Unicode 6.1.
- Issue #14040: Remove rarely used file name suffixes for C extensions - Issue #14040: Remove rarely used file name suffixes for C extensions
......
...@@ -3628,11 +3628,9 @@ call_find_module(PyObject *name, PyObject *path_list) ...@@ -3628,11 +3628,9 @@ call_find_module(PyObject *name, PyObject *path_list)
if (fd != -1) if (fd != -1)
fd = dup(fd); fd = dup(fd);
fclose(fp); fclose(fp);
if (fd == -1) {
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
}
fp = NULL; fp = NULL;
if (fd == -1)
return PyErr_SetFromErrno(PyExc_OSError);
} }
if (fd != -1) { if (fd != -1) {
if (strchr(fdp->mode, 'b') == NULL) { if (strchr(fdp->mode, 'b') == NULL) {
...@@ -3642,6 +3640,7 @@ call_find_module(PyObject *name, PyObject *path_list) ...@@ -3642,6 +3640,7 @@ call_find_module(PyObject *name, PyObject *path_list)
lseek(fd, 0, 0); /* Reset position */ lseek(fd, 0, 0); /* Reset position */
if (found_encoding == NULL && PyErr_Occurred()) { if (found_encoding == NULL && PyErr_Occurred()) {
Py_XDECREF(pathobj); Py_XDECREF(pathobj);
close(fd);
return NULL; return NULL;
} }
encoding = (found_encoding != NULL) ? found_encoding : encoding = (found_encoding != NULL) ? found_encoding :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment