Bug fixes for .so modules.

This commit is contained in:
Jeremy Fincher 2003-10-02 16:13:49 +00:00
parent ac78a1c2cb
commit 4bda1fc74a
2 changed files with 9 additions and 4 deletions

View File

@ -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)

View File

@ -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')