# Buggy code
def __init__(self, _id, dp_id, conf):
    self.rules = []
    self.exact_match = None
    self.meter = False
    self.matches = {}
    self.set_fields = set()
    conf = copy.deepcopy(conf)
    if isinstance(conf, dict):
        rules = conf.get("rules", [])
    elif isinstance(conf, list):
        rules = conf
        conf = {}
    else:
        raise InvalidConfigError("ACL conf is an invalid type %s" % _id)
    conf["rules"] = []
    for rule in rules:
        test_config_condition(
            not isinstance(rule, dict), ("ACL rule is %s not %s" % (type(rule), dict))
        )
        conf["rules"].append(rule.get("rule", rule))
    super(ACL, self).__init__(_id, dp_id, conf)


# Traceback (AttributeError)
Oct 25 16:13:59 faucet.exception ERROR    Unhandled exception, killing RYU
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/faucet/valve_util.py", line 34, in __koe
func(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/faucet/faucet.py", line 156, in reload_config
time.time(), self.config_file, delete_dp=self._delete_deconfigured_dp)
File "/usr/lib/python3.6/site-packages/faucet/valves_manager.py", line 139, in request_reload_configs
self.load_configs(now, new_config_file, delete_dp=delete_dp)
File "/usr/lib/python3.6/site-packages/faucet/valves_manager.py", line 108, in load_configs
new_dps = self.parse_configs(new_config_file)
File "/usr/lib/python3.6/site-packages/faucet/valves_manager.py", line 88, in parse_configs
new_config_hashes, new_dps = dp_parser(new_config_file, self.logname)
File "/usr/lib/python3.6/site-packages/faucet/config_parser.py", line 51, in dp_parser
config_hashes, dps = _config_parser_v2(config_file, logname)
File "/usr/lib/python3.6/site-packages/faucet/config_parser.py", line 213, in _config_parser_v2
top_confs['vlans'])
File "/usr/lib/python3.6/site-packages/faucet/config_parser.py", line 177, in _dp_parser_v2
for dp_key, dp_conf in dps_conf.items()]
File "/usr/lib/python3.6/site-packages/faucet/config_parser.py", line 177, in <listcomp>
for dp_key, dp_conf in dps_conf.items()]
File "/usr/lib/python3.6/site-packages/faucet/config_parser.py", line 161, in _parse_dp
acl = ACL(acl_key, dp_id, acl_conf)
File "/usr/lib/python3.6/site-packages/faucet/acl.py", line 118, in __init__
super(ACL, self).__init__(_id, dp_id, conf)
File "/usr/lib/python3.6/site-packages/faucet/conf.py", line 54, in __init__
self.check_config()
File "/usr/lib/python3.6/site-packages/faucet/acl.py", line 127, in check_config
self._check_conf_types(rule, self.rule_types)
File "/usr/lib/python3.6/site-packages/faucet/conf.py", line 76, in _check_conf_types
for conf_key, conf_value in conf.items():
AttributeError: 'NoneType' object has no attribute 'items'

# Fixed code
def __init__(self, _id, dp_id, conf):
    self.rules = []
    self.exact_match = None
    self.meter = False
    self.matches = {}
    self.set_fields = set()
    for match_fields in (MATCH_FIELDS, OLD_MATCH_FIELDS):
        self.rule_types.update({match: (str, int) for match in match_fields.keys()})
    conf = copy.deepcopy(conf)
    if isinstance(conf, dict):
        rules = conf.get("rules", [])
    elif isinstance(conf, list):
        rules = conf
        conf = {}
    else:
        raise InvalidConfigError("ACL conf is an invalid type %s" % _id)
    conf["rules"] = []
    for rule in rules:
        normalized_rule = rule
        if isinstance(rule, dict):
            normalized_rule = rule.get("rule", rule)
            if normalized_rule is None:
                normalized_rule = {k: v for k, v in rule.items() if v is not None}
        test_config_condition(
            not isinstance(normalized_rule, dict),
            ("ACL rule is %s not %s (%s)" % (type(normalized_rule), dict, rules)),
        )
        conf["rules"].append(normalized_rule)
    super(ACL, self).__init__(_id, dp_id, conf)