# Buggy code
def escape_format_string(cls, string):
    """
    Escapes curly braces from a PEP-3101's format string when there's a sequence of odd length
    """

    def escape_group_of_curly_braces(match):
        curlies = match.group()
        if len(curlies) % 2 == 1:
            curlies += curlies
        return curlies

    escaped_string = cls.CURLY_BRACES_REGEX.sub(escape_group_of_curly_braces, string)
    return escaped_string


# Traceback (ValueError)
crawler_1   | Temporarily disabling observer <twisted.logger._file.FileLogObserver object at 0x7f2956104ef0> due to exception: [Failure instance: Traceback: <class 'ValueError'>: Single '}' encountered in format string
crawler_1   | /usr/local/lib/python3.7/site-packages/monitor/crawler.py:323:learn_from_teacher_node
crawler_1   | /usr/local/lib/python3.7/site-packages/nucypher/network/nodes.py:794:learn_from_teacher_node
crawler_1   | /usr/local/lib/python3.7/site-packages/twisted/logger/_logger.py:238:warn
crawler_1   | /usr/local/lib/python3.7/site-packages/twisted/logger/_logger.py:144:emit
crawler_1   | --- <exception caught here> ---
crawler_1   | /usr/local/lib/python3.7/site-packages/twisted/logger/_observer.py:131:__call__
crawler_1   | /usr/local/lib/python3.7/site-packages/twisted/logger/_file.py:50:__call__
crawler_1   | /usr/local/lib/python3.7/site-packages/twisted/logger/_json.py:252:<lambda>
crawler_1   | /usr/local/lib/python3.7/site-packages/twisted/logger/_json.py:203:eventAsJSON
crawler_1   | /usr/local/lib/python3.7/site-packages/twisted/logger/_flatten.py:87:flattenEvent
crawler_1   | ]
crawler_1   | Traceback (most recent call last):
crawler_1   |   File "/usr/local/lib/python3.7/site-packages/monitor/crawler.py", line 323, in learn_from_teacher_node
crawler_1   |     new_nodes = super().learn_from_teacher_node(*args, **kwargs)
crawler_1   |   File "/usr/local/lib/python3.7/site-packages/nucypher/network/nodes.py", line 794, in learn_from_teacher_node
crawler_1   |     self.log.warn(f"Teacher {str(current_teacher)} is invalid: {bytes(current_teacher)}:{e}.")
crawler_1   |   File "/usr/local/lib/python3.7/site-packages/twisted/logger/_logger.py", line 238, in warn
crawler_1   |     self.emit(LogLevel.warn, format, **kwargs)
crawler_1   |   File "/usr/local/lib/python3.7/site-packages/twisted/logger/_logger.py", line 144, in emit
crawler_1   |     self.observer(event)
crawler_1   | --- <exception caught here> ---
crawler_1   |   File "/usr/local/lib/python3.7/site-packages/twisted/logger/_observer.py", line 131, in __call__
crawler_1   |     observer(event)
crawler_1   |   File "/usr/local/lib/python3.7/site-packages/twisted/logger/_file.py", line 50, in __call__
crawler_1   |     text = self.formatEvent(event)
crawler_1   |   File "/usr/local/lib/python3.7/site-packages/twisted/logger/_json.py", line 252, in <lambda>
crawler_1   |     lambda event: u"{0}{1}\n".format(recordSeparator, eventAsJSON(event))
crawler_1   |   File "/usr/local/lib/python3.7/site-packages/twisted/logger/_json.py", line 203, in eventAsJSON
crawler_1   |     flattenEvent(event)
crawler_1   |   File "/usr/local/lib/python3.7/site-packages/twisted/logger/_flatten.py", line 87, in flattenEvent
crawler_1   |     aFormatter.parse(event["log_format"])
crawler_1   | builtins.ValueError: Single '}' encountered in format string

# Fixed code
def escape_format_string(cls, string):
    """
    Escapes all curly braces from a PEP-3101's format string.
    """
    escaped_string = string.replace("{", "{{").replace("}", "}}")
    return escaped_string