<commit_before>
from _pydev_imps import _pydev_threading as threading
import functools


def wrapper(fun):
    def pydev_after_run_call():
        pass

    def inner(*args, **kwargs):
        fun(*args, **kwargs)
        pydev_after_run_call()
    return inner


def wrap_attr(obj, attr):
    t_save_start = getattr(obj, attr)
    setattr(obj, attr, wrapper(t_save_start))
    setattr(obj, "_pydev_run_patched", True)


class ObjectWrapper(object):
    def __init__(self, obj):
        self.wrapped_object = obj
        functools.update_wrapper(self, obj)

    def __getattr__(self, attr):
        orig_attr = getattr(self.wrapped_object, attr) #.__getattribute__(attr)
        if callable(orig_attr):
            def patched_attr(*args, **kwargs):
                self.call_begin(attr)
                result = orig_attr(*args, **kwargs)
                self.call_end(attr)
                if result == self.wrapped_object:
                    return self
                return result
            return patched_attr
        else:
            return orig_attr

    def call_begin(self, attr):
        pass
<commit_msg>Suppress exception while updating wrapper object in Python2 (PY-18078)<commit_after>from _pydev_imps import _pydev_threading as threading
import functools


def wrapper(fun):
    def pydev_after_run_call():
        pass

    def inner(*args, **kwargs):
        fun(*args, **kwargs)
        pydev_after_run_call()
    return inner


def wrap_attr(obj, attr):
    t_save_start = getattr(obj, attr)
    setattr(obj, attr, wrapper(t_save_start))
    setattr(obj, "_pydev_run_patched", True)


class ObjectWrapper(object):
    def __init__(self, obj):
        self.wrapped_object = obj
        try:
            functools.update_wrapper(self, obj)
        except:
            pass

    def __getattr__(self, attr):
        orig_attr = getattr(self.wrapped_object, attr) #.__getattribute__(attr)
        if callable(orig_attr):
            def patched_attr(*args, **kwargs):
                self.call_begin(attr)
                result = orig_attr(*args, **kwargs)
                self.call_end(attr)
                if result == self.wrapped_object:
                    return self
                return result
            return patched_attr
        else:
            return orig_attr

    def call_begin(self, attr):
        pass

{'fraction_non_alphanumeric': 0.08901192504258944, 'fraction_numerical': 0.002555366269165247, 'mean_word_length': 2.2355371900826446, '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': '1786429', 'n_tokens_mistral': 720, 'n_tokens_neox': 690, 'n_words': 162}