<commit_before># Module:   errors
# Date:     11th February 2009
# Author:   <NAME>, prologic at shortcircuit dot net dot au

"""Errors

This module implements a set of standard HTTP Errors.
"""

from cgi import escape

try:
    from urllib.parse import urljoin as _urljoin
except ImportError:
    from urlparse import urljoin as _urljoin  # NOQA

from circuits import Event

from ..six import string_types
from .constants import SERVER_URL, SERVER_VERSION
from .constants import DEFAULT_ERROR_MESSAGE, HTTP_STATUS_CODES


class httperror(Event):
    """An event for signaling an HTTP error"""

    code = 500
    description = ""
    contenttype = "text/html"

    def __init__(self, request, response, code=None, **kwargs):
        """
        The constructor creates a new instance and modifies the *response*
        argument to reflect the error.
        """
        super(httperror, self).__init__(request, response, code, **kwargs)

        self.request = request
        self.response = response

        if code is not None:
            self.code = code

        self.error = kwargs.get("error", None)

        self.description = kwargs.get(
            "description", getattr(self.__class__, "description", "")
        )

        if self.error is not None:
            self.traceback = "ERROR: (%s) %s\n%s" % (
                self.error[0], self.error[1], "".join(self.error[2])
            )
        else:
            self.traceback = ""

        self.response.close = True<commit_msg>Fixed httperror event<commit_after># Module:   errors
# Date:     11th February 2009
# Author:   <NAME>, prologic at shortcircuit dot net dot au

"""Errors

This module implements a set of standard HTTP Errors.
"""

from cgi import escape

try:
    from urllib.parse import urljoin as _urljoin
except ImportError:
    from urlparse import urljoin as _urljoin  # NOQA

from circuits import Event

from ..six import string_types
from .constants import SERVER_URL, SERVER_VERSION
from .constants import DEFAULT_ERROR_MESSAGE, HTTP_STATUS_CODES


class httperror(Event):
    """An event for signaling an HTTP error"""

    code = 500
    description = ""
    contenttype = "text/html"

    def __init__(self, request, response, code=None, **kwargs):
        """
        The constructor creates a new instance and modifies the *response*
        argument to reflect the error.
        """
        super(httperror, self).__init__(request, response, code, **kwargs)

        # Override HTTPError subclasses
        self.name = "httperror"

        self.request = request
        self.response = response

        if code is not None:
            self.code = code

        self.error = kwargs.get("error", None)

        self.description = kwargs.get(
            "description", getattr(self.__class__, "description", "")
        )

        if self.error is not None:
            self.traceback = "ERROR: (%s) %s\n%s" % (
                self.error[0], self.error[1], "".join(self.error[2])
            )
        else:
            self.traceback = ""

        self.response.close = True
{'fraction_non_alphanumeric': 0.09788617886178862, 'fraction_numerical': 0.007804878048780488, 'mean_word_length': 2.463963963963964, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4474291', 'n_tokens_mistral': 898, 'n_tokens_neox': 862, 'n_words': 284}