saltstack/salt — Issue #411: The `try:import..except:pass` block in `salt/__init__py` masks real import problems
Author: akaihola
Created: 2012-01-03 08:01:38+00:00
State: open

In `salt/__init__.py`, the following block eats all exceptions which happen during importing salt modules:

# Import salt libs, the try block bypasses an issue at build time so that c
# modules don't cause the build to fail
try:
import salt.config
import salt.utils.verify
except ImportError:
pass

For example, if the yaml library isn't installed, `salt-master` throws the following error (using a virtualenv at `/tmp/salttest` here):

Traceback (most recent call last):
File "/tmp/salttest/bin/salt-master", line 17, in
main()
File "/tmp/salttest/bin/salt-master", line 13, in main
master = salt.Master()
File "/tmp/salttest/local/lib/python2.7/site-packages/salt/__init__.py", line 42, in __init__
self.opts = salt.config.master_config(self.cli['config'])
NameError: global name 'salt' is not defined

The real reason `salt` is not defined is that `import yaml` failed.

I tried removing the `try..except`, and `python setup.py install` still works and compiles the C extension correctly.

See https://groups.google.com/forum/#!topic/salt-users/fmUQjdqBAJU for some discussion about this.