3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-30 23:09:23 +01:00

corecommands: really fix 'reload'

(cherry picked from commit 150bfe8c66)
This commit is contained in:
James Lu 2016-07-23 21:59:25 -07:00
parent d3ca49ceeb
commit e342889937

View File

@ -72,7 +72,7 @@ def load(irc, source, args):
return return
log.info('(%s) Loading plugin %r for %s', irc.name, name, irc.getHostmask(source)) log.info('(%s) Loading plugin %r for %s', irc.name, name, irc.getHostmask(source))
try: try:
world.plugins[name] = pl = importlib.reload(utils.loadPlugin(name)) world.plugins[name] = pl = utils.loadPlugin(name)
except ImportError as e: except ImportError as e:
if str(e) == ('No module named %r' % name): if str(e) == ('No module named %r' % name):
log.exception('Failed to load plugin %r: The plugin could not be found.', name) log.exception('Failed to load plugin %r: The plugin could not be found.', name)
@ -139,10 +139,11 @@ def unload(irc, source, args):
# Delete it from memory (hopefully). # Delete it from memory (hopefully).
del world.plugins[name] del world.plugins[name]
if name in sys.modules: for n in (name, modulename):
del sys.modules[name] if n in sys.modules:
if name in globals(): del sys.modules[n]
del globals()[name] if n in globals():
del globals()[n]
# Garbage collect. # Garbage collect.
gc.collect() gc.collect()