Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 48189:53ade9e68b56 legacy-trunk
Add imp.reload(). This to help with transitioning to 3.0 the reload() built-in
has been removed there.
| author | Brett Cannon <bcannon@gmail.com> |
|---|---|
| date | Wed, 06 Aug 2008 22:28:09 +0000 |
| parents | b90752c5e8c1 |
| children | 176c409fd747 |
line wrap: on
line diff
--- a/Python/import.c Wed Aug 06 21:36:57 2008 +0000 +++ b/Python/import.c Wed Aug 06 22:28:09 2008 +0000 @@ -3030,12 +3030,24 @@ 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 @@ 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},
