<commit_before>require 'utilrb/common'

Utilrb.require_ext("Utilrb::WeakRef") do
    module Utilrb
        class WeakRef
            def initialize(obj)
                if obj.kind_of?(WeakRef)
                    raise ArgumentError, "cannot create a weakref of a weakref"
                end
                unless WeakRef.refcount(obj)
                    ObjectSpace.define_finalizer(obj, self.class.method(:do_object_finalize))
                end<commit_msg>fix error raised by WeakRef when the argument is frozen<commit_after>require 'utilrb/common'

Utilrb.require_ext("Utilrb::WeakRef") do
    module Utilrb
        class WeakRef
            def initialize(obj)
                if obj.kind_of?(WeakRef)
                    raise ArgumentError, "cannot create a weakref of a weakref"
                end
                unless WeakRef.refcount(obj)
                    begin
                        ObjectSpace.define_finalizer(obj, self.class.method(:do_object_finalize))
                    rescue RuntimeError => e
                        raise ArgumentError, "cannot define finalizer for #{obj}", e.backtrace
                    end
                end
{'fraction_non_alphanumeric': 0.06701030927835051, 'fraction_numerical': 0.0, 'mean_word_length': 1.665903890160183, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '5356709', 'n_tokens_mistral': 309, 'n_tokens_neox': 283, 'n_words': 78}