summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2008-08-06 22:28:09 (GMT)
committerBrett Cannon <bcannon@gmail.com>2008-08-06 22:28:09 (GMT)
commit3aa2a49ec97d8a56f7f748116d8cd584185c301d (patch)
tree0bbbae6149e106cf841060696175d5a7776f49aa /Python
parentc777a412f1e8c691eb25074bf85c4e8ca854f038 (diff)
downloadcpython-3aa2a49ec97d8a56f7f748116d8cd584185c301d.zip
cpython-3aa2a49ec97d8a56f7f748116d8cd584185c301d.tar.gz
cpython-3aa2a49ec97d8a56f7f748116d8cd584185c301d.tar.bz2
Add imp.reload(). This to help with transitioning to 3.0 the reload() built-in
has been removed there.
Diffstat (limited to 'Python')
-rw-r--r--Python/import.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/Python/import.c b/Python/import.c
index f0ee40a..fd13154 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -3030,12 +3030,24 @@ imp_new_module(PyObject *self, PyObject *args)
return PyModule_New(name);
}
+static PyObject *
+imp_reload(PyObject *self, PyObject *v)
+{
+ return PyImport_ReloadModule(v);
+}
+
+
/* Doc strings */
PyDoc_STRVAR(doc_imp,
"This module provides the components needed to build your own\n\
__import__ function. Undocumented functions are obsolete.");
+PyDoc_STRVAR(doc_reload,
+"reload(module) -> module\n\
+\n\
+Reload the module. The module must have been successfully imported before.");
+
PyDoc_STRVAR(doc_find_module,
"find_module(name, [path]) -> (file, filename, (suffix, mode, type))\n\
Search for a module. If path is omitted or None, search for a\n\
@@ -3080,6 +3092,7 @@ Release the interpreter's import lock.\n\
On platforms without threads, this function does nothing.");
static PyMethodDef imp_methods[] = {
+ {"reload", imp_reload, METH_O, doc_reload},
{"find_module", imp_find_module, METH_VARARGS, doc_find_module},
{"get_magic", imp_get_magic, METH_NOARGS, doc_get_magic},
{"get_suffixes", imp_get_suffixes, METH_NOARGS, doc_get_suffixes},