# Buggy code
def __init__(self, opts, timeout=60, safe=True, loaded_base_name=None, io_loop=None):  # pylint: disable=W0231
    """
    Pass in the options dict
    """
    # this means that the parent class doesn't know *which* master we connect to
    super(Minion, self).__init__(opts)
    self.timeout = timeout
    self.safe = safe

    self._running = None
    self.win_proc = []
    self.loaded_base_name = loaded_base_name

    self.io_loop = io_loop or zmq.eventloop.ioloop.ZMQIOLoop()
    if not self.io_loop.initialized():
        self.io_loop.install()

    # Warn if ZMQ < 3.2
    if HAS_ZMQ:
        try:
            zmq_version_info = zmq.zmq_version_info()
        except AttributeError:
            # PyZMQ <= 2.1.9 does not have zmq_version_info, fall back to
            # using zmq.zmq_version() and build a version info tuple.
            zmq_version_info = tuple([int(x) for x in zmq.zmq_version().split(".")])
        if zmq_version_info < (3, 2):
            log.warning(
                "You have a version of ZMQ less than ZMQ 3.2! There are "
                "known connection keep-alive issues with ZMQ < 3.2 which "
                "may result in loss of contact with minions. Please "
                "upgrade your ZMQ!"
            )
    # Late setup the of the opts grains, so we can log from the grains
    # module.  If this is a proxy, however, we need to init the proxymodule
    # before we can get the grains.  We do this for proxies in the
    # post_master_init
    if not salt.utils.is_proxy():
        self.opts["grains"] = salt.loader.grains(opts)


# Traceback (TypeError)
2016-04-15 13:23:12,471 [salt.minion      ][ERROR   ] No master could be reached or all masters denied the minions connection attempt.
2016-04-15 13:23:12,473 [tornado.application][ERROR   ] Exception in callback <functools.partial object at 0x7fbd0876e158>
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/tornado/ioloop.py", line 592, in _run_callback
ret = callback()
File "/usr/lib/python2.7/dist-packages/tornado/stack_context.py", line 275, in null_wrapper
return fn(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/tornado/ioloop.py", line 598, in <lambda>
self.add_future(ret, lambda f: f.result())
File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 215, in result
raise_exc_info(self._exc_info)
File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 879, in run
yielded = self.gen.send(value)
File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 1608, in handle_event
failed=True)
TypeError: 'NoneType' object is not iterable

# Fixed code
def __init__(self, opts, timeout=60, safe=True, loaded_base_name=None, io_loop=None):  # pylint: disable=W0231
    """
    Pass in the options dict
    """
    # this means that the parent class doesn't know *which* master we connect to
    super(Minion, self).__init__(opts)
    self.timeout = timeout
    self.safe = safe

    self._running = None
    self.win_proc = []
    self.loaded_base_name = loaded_base_name
    self.restart = False

    self.io_loop = io_loop or zmq.eventloop.ioloop.ZMQIOLoop()
    if not self.io_loop.initialized():
        self.io_loop.install()

    # Warn if ZMQ < 3.2
    if HAS_ZMQ:
        try:
            zmq_version_info = zmq.zmq_version_info()
        except AttributeError:
            # PyZMQ <= 2.1.9 does not have zmq_version_info, fall back to
            # using zmq.zmq_version() and build a version info tuple.
            zmq_version_info = tuple([int(x) for x in zmq.zmq_version().split(".")])
        if zmq_version_info < (3, 2):
            log.warning(
                "You have a version of ZMQ less than ZMQ 3.2! There are "
                "known connection keep-alive issues with ZMQ < 3.2 which "
                "may result in loss of contact with minions. Please "
                "upgrade your ZMQ!"
            )
    # Late setup the of the opts grains, so we can log from the grains
    # module.  If this is a proxy, however, we need to init the proxymodule
    # before we can get the grains.  We do this for proxies in the
    # post_master_init
    if not salt.utils.is_proxy():
        self.opts["grains"] = salt.loader.grains(opts)