Merge lp:~pconnell/endroid/bugfix into lp:endroid

Proposed by Phil Connell
Status: Merged
Approved by: Phil Connell
Approved revision: 79
Merged at revision: 79
Proposed branch: lp:~pconnell/endroid/bugfix
Merge into: lp:endroid
Diff against target: 14 lines (+2/-2)
1 file modified
src/endroid/plugins/command.py (+2/-2)
To merge this branch: bzr merge lp:~pconnell/endroid/bugfix
Reviewer Review Type Date Requested Status
Patrick Stevens Approve
Review via email: mp+231545@code.launchpad.net

Commit message

Allow command plugin dependencies to be specified in any iterable type.

    Previously plugin.dependencies was forced to be a tuple. A naive change in the
    SMS plugin hit this restriction:

    >>> import endroid.plugins.sms
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python2.7/dist-packages/endroid/plugins/sms/__init__.py", line 27, in <module>
        class SMS(CommandPlugin):
      File "/usr/lib/python2.7/dist-packages/endroid/plugins/command.py", line 158, in __new__
        ('endroid.plugins.command',))
    TypeError: Error when calling the metaclass bases
        can only concatenate list (not "tuple") to list

    Rather than changing the SMS plugin, it's better to make the command plugin
    more lenient.

Description of the change

Recent changes to the SMS plugin exposed a bug in command plugin dependency handling: dependencies had to be specified as a tuple. SMS was using a list, meaning attempts to import it failed:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/endroid/plugins/sms/__init__.py", line 27, in <module>
    class SMS(CommandPlugin):
  File "/usr/lib/python2.7/dist-packages/endroid/plugins/command.py", line 158, in __new__
    ('endroid.plugins.command',))
TypeError: Error when calling the metaclass bases
    can only concatenate list (not "tuple") to list

Update Command to allow any iterable instead. It looks like the old code attempted to do this (just passed the wrong arg to tuple()).

To post a comment you must log in.
Revision history for this message
Patrick Stevens (patrickas) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/endroid/plugins/command.py'
2--- src/endroid/plugins/command.py 2013-08-21 22:06:20 +0000
3+++ src/endroid/plugins/command.py 2014-08-20 12:16:20 +0000
4@@ -154,8 +154,8 @@
5 dct['_help_topics'] = topics
6 dct['help_topics'] = _Topics
7
8- dct['dependencies'] = tuple(dct.get('dependencies', ()) +
9- ('endroid.plugins.command',))
10+ dct['dependencies'] = (tuple(dct.get('dependencies', ())) +
11+ ('endroid.plugins.command',))
12 return super(CommandPluginMeta, meta).__new__(meta, name, bases, dct)
13
14 class CommandPlugin(Plugin):

Subscribers

People subscribed via source and target branches