<commit_before>import datetime
import html

from webob.exc import HTTPInternalServerError


class ConfigurationError(Exception):

    """Exception used to indicate a configuration error."""


class DebugHTTPInternalServerError(HTTPInternalServerError):

    """For use in debug mode, mainly for showing tracebacks."""

    body_template = '<pre>{timestamp}\n\n{content}</pre>'

    def __init__(self, content, *args, **kwargs):
        now = datetime.datetime.now()
        content = html.escape(content)
        body_template = self.body_template.format(
            timestamp=now, content=content)
        super().__init__(body_template=body_template, *args, **kwargs)
<commit_msg>Add a hack so weird chars don't cause issues<commit_after>import datetime
import html

from webob.exc import HTTPInternalServerError


class ConfigurationError(Exception):

    """Exception used to indicate a configuration error."""


class DebugHTTPInternalServerError(HTTPInternalServerError):

    """For use in debug mode, mainly for showing tracebacks."""

    body_template = '<pre>{timestamp}\n\n{content}</pre>'

    def __init__(self, content, *args, **kwargs):
        now = datetime.datetime.now()
        content = html.escape(content)
        body_template = self.body_template.format(
            timestamp=now, content=content)
        super().__init__(body_template=body_template, *args, **kwargs)

        # HACK
        safe_substitue = self.body_template_obj.safe_substitute
        self.body_template_obj.substitute = safe_substitue

{'fraction_non_alphanumeric': 0.10416666666666667, 'fraction_numerical': 0.0, 'mean_word_length': 3.99025974025974, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4396397', 'n_tokens_mistral': 420, 'n_tokens_neox': 400, 'n_words': 105}