diff --git a/plugins/Python.py b/plugins/Python.py index fed68a9e9..fbdf43d00 100644 --- a/plugins/Python.py +++ b/plugins/Python.py @@ -38,6 +38,7 @@ from baseplugin import * import os import imp +import crypt import random # Stupid printing on import... @@ -50,6 +51,7 @@ import utils import privmsgs import callbacks +pythonPath = map(os.path.dirname, [os.__file__, crypt.__file__]) def configure(onStart, afterConnect, advanced): # This will be called by setup.py to configure this module. onStart and @@ -77,15 +79,15 @@ class Python(callbacks.Privmsg): if '.' in funcname: parts = funcname.split('.') functionName = parts.pop() - path = os.path.dirname(os.__file__) + path = pythonPath for name in parts: try: - info = imp.find_module(name, [path]) + info = imp.find_module(name, path) newmodule = imp.load_module(name, *info) - path = os.path.dirname(newmodule.__file__) + path = [os.path.dirname(newmodule.__file__)] info[0].close() except ImportError: - irc.error(msg, 'No such module %s exists.' % module) + irc.error(msg, 'No such module %s exists.' % name) return if hasattr(newmodule, functionName): f = getattr(newmodule, functionName) diff --git a/test/test_Python.py b/test/test_Python.py index a3dd2b6c7..5ba158481 100644 --- a/test/test_Python.py +++ b/test/test_Python.py @@ -37,6 +37,9 @@ class PythonTestCase(PluginTestCase, PluginDocumentation): self.assertError('pydoc foobar') self.assertError('pydoc assert') self.assertNotError('pydoc str') + self.assertNotRegexp('pydoc crypt.crypt', 'NameError') + self.assertNotError('pydoc crypt.crypt') + self.assertNotError('pydoc math.sin') self.assertNotError('pydoc string.translate') self.assertNotError('pydoc fnmatch.fnmatch') self.assertNotError('pydoc socket.socket')