rackerlabs / lambda-uploader

Helps package and upload Python lambda functions to AWS
Apache License 2.0
271 stars 56 forks source link

_python_executable in package.py doesn't check for None #97

Closed martinb3 closed 8 years ago

martinb3 commented 8 years ago

@horacio3 is seeing the following stack trace:

⁉️ Unexpected error. Please report this traceback.
Traceback (most recent call last):
  File "build\bdist.win32\egg\lambda_uploader\shell.py", line 173, in main
    _execute(args)
  File "build\bdist.win32\egg\lambda_uploader\shell.py", line 73, in _execute
    venv, cfg.ignore, extra_files)
  File "build\bdist.win32\egg\lambda_uploader\package.py", line 47, in build_package
    pkg.build(ignore)
  File "build\bdist.win32\egg\lambda_uploader\package.py", line 68, in build
    self.install_dependencies()
  File "build\bdist.win32\egg\lambda_uploader\package.py", line 140, in install_dependencies
    self._build_new_virtualenv()
  File "build\bdist.win32\egg\lambda_uploader\package.py", line 167, in _build_new_virtualenv
    self._pkg_venv], stdout=PIPE, stderr=PIPE)
  File "C:\Python27\lib\subprocess.py", line 710, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 913, in _execute_child
    args = list2cmdline(args)
  File "C:\Python27\lib\subprocess.py", line 616, in list2cmdline
    needquote = (" " in arg) or ("\t" in arg) or not arg
TypeError: argument of type 'NoneType' is not iterable

It boils down to _find_executable not handling None returned from find_executable:

def _python_executable():
        python_exe = find_executable('python2')
        if python_exe is '':
            python_exe = find_executable('python')

        if python_exe is '':
            raise Exception('Unable to locate python executable')

        return python_exe

Example of find_executable output on Horacio's box:

from distutils.spawn import find_executable
>>> print(find_executable('python2'))
None
>>> print(find_executable('python'))
C:\Python27\python.exe

So then None is returned from _python_executable and this line barfs when you try to pass None as an argument to Popen.