summaryrefslogtreecommitdiff
path: root/Python/import.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-09-23 19:37:03 +0200
committerVictor Stinner <victor.stinner@haypocalc.com>2011-09-23 19:37:03 +0200
commit63c22fac727a72f0a4da8f72b12cd5f9b480376b (patch)
tree8c3da37f17c59c36e9204e527c1ceea2a48695f7 /Python/import.c
parent51b719814e0c32fd0eea570d3769d323bea97cab (diff)
downloadcpython-git-63c22fac727a72f0a4da8f72b12cd5f9b480376b.tar.gz
Issue #7732: Fix a crash on importing a module if a directory has the same name
than a Python module (e.g. "__init__.py"): don't close the file twice. PyFile_FromFile() does also close the file if PyString_FromString() failed. It did already close the file on fill_file_fields() error (e.g. if the file is a directory).
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/Python/import.c b/Python/import.c
index 673d1b3324..c60ecfea5e 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -2845,10 +2845,8 @@ call_find_module(char *name, PyObject *path)
return NULL;
if (fp != NULL) {
fob = PyFile_FromFile(fp, pathname, fdp->mode, fclose);
- if (fob == NULL) {
- fclose(fp);
+ if (fob == NULL)
return NULL;
- }
}
else {
fob = Py_None;