diff options
author | Phillip J. Eby <pje@telecommunity.com> | 2004-09-23 04:37:36 (GMT) |
---|---|---|
committer | Phillip J. Eby <pje@telecommunity.com> | 2004-09-23 04:37:36 (GMT) |
commit | 7ec642a4d2ee98dfc0b67431255046374abc4ed7 (patch) | |
tree | b018d53945c80947cd15fa8efe369fac64d7657a /Python | |
parent | f4aca755bc9f26b51b6820a162a3f76c2a1a1abc (diff) | |
download | cpython-7ec642a4d2ee98dfc0b67431255046374abc4ed7.zip cpython-7ec642a4d2ee98dfc0b67431255046374abc4ed7.tar.gz cpython-7ec642a4d2ee98dfc0b67431255046374abc4ed7.tar.bz2 |
Fix for SF bug #1029475 : reload() doesn't work with PEP 302 loaders.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/import.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Python/import.c b/Python/import.c index 61e4313..8f81d6e 100644 --- a/Python/import.c +++ b/Python/import.c @@ -2252,7 +2252,7 @@ PyObject * PyImport_ReloadModule(PyObject *m) { PyObject *modules = PyImport_GetModuleDict(); - PyObject *path = NULL; + PyObject *path = NULL, *loader = NULL; char *name, *subname; char buf[MAXPATHLEN+1]; struct filedescr *fdp; @@ -2295,11 +2295,17 @@ PyImport_ReloadModule(PyObject *m) PyErr_Clear(); } buf[0] = '\0'; - fdp = find_module(name, subname, path, buf, MAXPATHLEN+1, &fp, NULL); + fdp = find_module(name, subname, path, buf, MAXPATHLEN+1, &fp, &loader); Py_XDECREF(path); - if (fdp == NULL) + + if (fdp == NULL) { + Py_XDECREF(loader); return NULL; - newm = load_module(name, fp, buf, fdp->type, NULL); + } + + newm = load_module(name, fp, buf, fdp->type, loader); + Py_XDECREF(loader); + if (fp) fclose(fp); if (newm == NULL) { |