<commit_before>class UnitOrders(object):
    def __init__(self):
        self.orders = {}

    def giveOrders(self, unit, orders):
        if orders is not None and not isinstance(orders, list):
            orders = list(orders)
        self.orders[unit] = orders

    def getNextOrder(self, unit):
        try:
            return self.orders[unit][0]
        except (KeyError, IndexError):
            return None

    def removeNextOrder(self, unit):
        self.orders[unit] = self.orders[unit][1:]
        if not self.orders[unit]:
            del self.orders[unit]

    def getAllUnitsNextOrders(self):
        return {x: self.getNextOrder(x) for x in self.orders}

<commit_msg>Check for None before indexing.<commit_after>class UnitOrders(object):
    def __init__(self):
        self.orders = {}

    def giveOrders(self, unit, orders):
        if orders is not None and not isinstance(orders, list):
            orders = list(orders)
        self.orders[unit] = orders

    def getNextOrder(self, unit):
        try:
            orders = self.orders[unit]
            if orders is None:
                return None
            else:
                return orders[0]
        except (KeyError, IndexError):
            return None

    def removeNextOrder(self, unit):
        self.orders[unit] = self.orders[unit][1:]
        if not self.orders[unit]:
            del self.orders[unit]

    def getAllUnitsNextOrders(self):
        return {x: self.getNextOrder(x) for x in self.orders}


{'fraction_non_alphanumeric': 0.10167224080267559, 'fraction_numerical': 0.0026755852842809363, 'mean_word_length': 2.1297071129707112, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6312627', 'n_tokens_mistral': 435, 'n_tokens_neox': 422, 'n_words': 117}