<commit_before>from libc.stdio cimport fopen, fclose, fread, fwrite, FILE


cdef class CFile:
    def __init__(self, loc, bytes mode):
        cdef bytes bytes_loc = loc.encode('utf8') if type(loc) == unicode else loc
        self.fp = fopen(<char*>bytes_loc, mode)
        if self.fp == NULL:
            raise IOError("Could not open binary file %s" % bytes_loc)
        self.is_open = True

    def __dealloc__(self):
        if self.is_open:
            fclose(self.fp)

    def close(self):
        fclose(self.fp)
        self.is_open = False
<commit_msg>* Fix typing on mode string in CFile<commit_after>from libc.stdio cimport fopen, fclose, fread, fwrite, FILE


cdef class CFile:
    def __init__(self, loc, mode):
        if isinstance(mode, unicode):
            mode_str = mode.decode('ascii')
        cdef bytes bytes_loc = loc.encode('utf8') if type(loc) == unicode else loc
        self.fp = fopen(<char*>bytes_loc, mode)
        if self.fp == NULL:
            raise IOError("Could not open binary file %s" % bytes_loc)
        self.is_open = True

    def __dealloc__(self):
        if self.is_open:
            fclose(self.fp)

    def close(self):
        fclose(self.fp)
        self.is_open = False

{'fraction_non_alphanumeric': 0.10728910728910729, 'fraction_numerical': 0.001638001638001638, 'mean_word_length': 2.3944444444444444, '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': '3987130', 'n_tokens_mistral': 405, 'n_tokens_neox': 388, 'n_words': 113}