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

TypeError is raised instead of CommandNotFound for missing executables #113

Closed
xapple opened this issue Jan 8, 2013 · 4 comments
Closed

Comments

@xapple
Copy link

xapple commented Jan 8, 2013

I have an executable in my $PATH named module. I can't seem to execute it with sh. Here is the traceback:

In [1]: import sh

In [2]: module = sh.Command('module')

In [3]: module()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-738a174178d6> in <module>()
----> 1 module()

../python2.7/site-packages/sh-1.07-py2.7.egg/sh.pyc in __call__(self, *args, **kwargs)
    646 
    647 
--> 648         return RunningCommand(cmd, call_args, stdin, stdout, stderr)
    649 
    650 

../python2.7/site-packages/sh-1.07-py2.7.egg/sh.pyc in __init__(self, cmd, call_args, stdin, stdout, stderr)
    221         self.call_args = call_args
    222         self.cmd = cmd
--> 223         self.ran = " ".join(cmd)
    224         self.process = None
    225 

TypeError: sequence item 0: expected string, NoneType found
@amoffat
Copy link
Owner

amoffat commented Jan 9, 2013

The output is not what I expected, and I was able to confirm that, but try entering the full path to "module" and tell me if that works:

import sh
module = sh.Command("/path/to/module")
module()

@xapple
Copy link
Author

xapple commented Jan 9, 2013

Ah, sorry I was probably a bit quick on reporting that bug. Actually, I hadn't realized but what I thought was an executable called module was just a bash function defined in some rc file. The same happens with random names: a TypeError is raised instead of a CommandNotFound.

In [9]: i = sh.Command("lololo")

In [10]: i()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-fa1b63ea38ec> in <module>()
----> 1 i()

../python2.7/site-packages/sh-1.07-py2.7.egg/sh.pyc in __call__(self, *args, **kwargs)
    646 
    647 
--> 648         return RunningCommand(cmd, call_args, stdin, stdout, stderr)
    649 
    650 

../python2.7/site-packages/sh-1.07-py2.7.egg/sh.pyc in __init__(self, cmd, call_args, stdin, stdout, stderr)
    221         self.call_args = call_args
    222         self.cmd = cmd
--> 223         self.ran = " ".join(cmd)
    224         self.process = None
    225 

TypeError: sequence item 0: expected string, NoneType found 

@amoffat
Copy link
Owner

amoffat commented Jan 9, 2013

Yeah that's bug..it should be raising CommandNotFound. Glad you solved your other issue. I'll take a look at this

@amoffat
Copy link
Owner

amoffat commented Jan 30, 2013

fixed in 1.08

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

No branches or pull requests

2 participants