Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plumbum LocalModule does not respect getattr default value #135

Merged
merged 2 commits into from
Jul 1, 2014

Conversation

idanz
Copy link
Contributor

@idanz idanz commented Jul 1, 2014

e.g.

> getattr(sys.modules['plumbum.cmd'], 'x', None)
---------------------------------------------------------------------------
CommandNotFound                           Traceback (most recent call last)
<ipython-input-13-f6036372bef1> in <module>()
----> 1 getattr(sys.modules['plumbum.cmd'], 'x', None)

/usr/local/lib/python2.7/dist-packages/plumbum/machines/local.pyc in __getitem__(self, cmd)
    195             else:
    196                 # search for command
--> 197                 return LocalCommand(self.which(cmd))
    198         else:
    199             raise TypeError("cmd must not be a RemotePath: %r" % (cmd,))

/usr/local/lib/python2.7/dist-packages/plumbum/machines/local.pyc in which(cls, progname)
    166             if path:
    167                 return path
--> 168         raise CommandNotFound(progname, list(cls.env.path))
    169
    170     def path(self, *parts):

CommandNotFound: ('x', [<LocalPath /usr/local/sbin>, <LocalPath /usr/local/bin>, <LocalPath /usr/sbin>, <LocalPath /usr/bin>, <LocalPath /sbin>, <LocalPath /bin>, <LocalPath /usr/games>, <LocalPath /opt/vagrant_ruby/bin>, <LocalPath /home/vagrant/qlika-dev>])

This can cause serious issues, for example, it breaks pickle.whichmodule.

To fix, plumbum should raise AttributeError if getitem fails when called from getattr

@tomerfiliba tomerfiliba merged commit cbe9c34 into tomerfiliba:master Jul 1, 2014
@tomerfiliba
Copy link
Owner

thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants