<commit_before>'''
This module holds root exception types, as well as mix-ins
that can be subclassed for user code or used in try/except blocks
'''
import sys


class ASFError(Exception):
    """
    This exception is kind of nice because it can wrap an existing
    exception and save information, such as the stack trace, from the
    time of Exception creation.
    """
    def __init__(self, exception=None):
        Exception.__init__(self, exception)
        if exception:
            if isinstance(exception, BaseException):
                self.exception = exception
                exc_type, exc_value = sys.exc_info()[:2]
                if exc_value == exception:
                    exc_parts = traceback.format_exception_only(exc_type,
                                                                exc_value)
                    self.exc_string = ''.join(exc_parts)
                    self.stack_trace = ''.join(traceback.format_exc())
                else:
                    ecn = exception.__class__.__name__
                    self.exc_string = '%s: %s' % (ecn, exception)
            elif isinstance(exception, basestring):
                self.exception = self
                self.exc_string = "ASFError: " + exception
            else:
                self.exception = Exception(exception)<commit_msg>fixed import error on rarely used codepath<commit_after>'''
This module holds root exception types, as well as mix-ins
that can be subclassed for user code or used in try/except blocks
'''
import sys
import traceback

class ASFError(Exception):
    """
    This exception is kind of nice because it can wrap an existing
    exception and save information, such as the stack trace, from the
    time of Exception creation.
    """
    def __init__(self, exception=None):
        Exception.__init__(self, exception)
        if exception:
            if isinstance(exception, BaseException):
                self.exception = exception
                exc_type, exc_value = sys.exc_info()[:2]
                if exc_value == exception:
                    exc_parts = traceback.format_exception_only(exc_type,
                                                                exc_value)
                    self.exc_string = ''.join(exc_parts)
                    self.stack_trace = ''.join(traceback.format_exc())
                else:
                    ecn = exception.__class__.__name__
                    self.exc_string = '%s: %s' % (ecn, exception)
            elif isinstance(exception, basestring):
                self.exception = self
                self.exc_string = "ASFError: " + exception
            else:
                self.exception = Exception(exception)
{'fraction_non_alphanumeric': 0.07780659503519823, 'fraction_numerical': 0.0007410151908114116, 'mean_word_length': 1.7551020408163265, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '52378', 'n_tokens_mistral': 661, 'n_tokens_neox': 633, 'n_words': 203}