Skip to content

Commit e556bb7

Browse files
jlu5progval
authored andcommitted
Ignore stale renames defined for nonexistent commands
Closes #1619
1 parent 7851418 commit e556bb7

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

plugins/Owner/test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,16 @@ def testRenameNested(self):
157157
self.assertRegexp('list Admin', 'capability remove')
158158
self.assertNotRegexp('list Admin', 'rmcap')
159159

160+
def testIgnoreStaleRenames(self):
161+
"""
162+
Test that stale renames in the config don't cause loading a plugin
163+
to fail, if a command ever gets removed.
164+
https://github.com/progval/Limnoria/issues/1619
165+
"""
166+
plugin.registerRename(
167+
'Utilities', command='nonexistent', newName='test')
168+
self.assertNotError('load Utilities')
169+
160170
def testDefaultPluginErrorsWhenCommandNotInPlugin(self):
161171
self.assertError('defaultplugin foobar owner')
162172

src/plugin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,11 @@ def renameCommand(cb, name, newName):
130130
assert newName == callbacks.canonicalName(newName), \
131131
'newName must already be normalized.'
132132
if name != newName:
133-
method = getattr(cb.__class__, name)
133+
method = getattr(cb.__class__, name, None)
134+
if method is None:
135+
log.debug('Ignoring rename of command %s.%s that no longer exists',
136+
cb.__class__.__name__, name)
137+
return
134138
setattr(cb.__class__, newName, method)
135139
delattr(cb.__class__, name)
136140

0 commit comments

Comments
 (0)