fix and test for issue 1365: exception subclasses should not be recog… #1372

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@mattvonrocketstein

…nized as fabric commands

@kaaveland kaaveland commented on the diff Dec 16, 2015
fabric/main.py
@@ -125,6 +126,7 @@ def is_classic_task(tup):
callable(func)
and (func not in _internals)
and not name.startswith('_')
+ and not (inspect.isclass(func) and issubclass(func, Exception))
@kaaveland
kaaveland Dec 16, 2015

I'm wondering to myself if it makes sense that any class is a task? I'm wondering if maybe we should just refuse classes. Suppose I want to generate some csv from a bunch of servers and I put the following in my file: from csv import CsvWriter, Dialect -- with current master, fabric will list Dialect Describe an Excel dialect. in fab -l.

@mattvonrocketstein
mattvonrocketstein Dec 16, 2015

I think what you say is totally reasonable, and would be all for excluding all classes and not just exception subclasses.

FWIW, I made this change for exceptions only because it seemed like a good combination of useful/safe. It's useful because, for quick fabfiles, I'm betting exceptions are imported more often than classes. It's safe because even though there's probably one maniac out there that has some crazy work flow that depends on the existing fabfile behaviour with respect to classes, surely no one is counting on the existing Exception behaviour, right?

@kaaveland
kaaveland Dec 17, 2015

Fair enough, I do agree that some crazy person could be using __init__ as a task and I agree this seems less likely to break for anyone.

@bitprophet
bitprophet Dec 17, 2015 Member

Class-based tasks are actually a definite (if minority) use case, so the limitation of "it's an Exception" should stay, IMHO.

@bitprophet
Member

Dropping #1365 here for linkage.

@bitprophet bitprophet added this to the 1.10.3 milestone Dec 17, 2015
@bitprophet bitprophet added the Bug label Dec 17, 2015
@bitprophet
Member

Cherry-picked to 1.10 branch as 4e1fd83 - closing & releasing soon, thanks!

@bitprophet bitprophet closed this Apr 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment