<commit_before># mode: run

from cpython.pythread cimport *

def tss_create_delete():
    """
    >>> tss_create_delete()
    (True, False)
    """
    cdef Py_tss_t tss_key = Py_tss_NEEDS_INIT
    cdef bint after_create, after_delete
    if PyThread_tss_create(&tss_key) > 0:
        # handle key creation failure
        pass
    after_create = PyThread_tss_is_created(&tss_key) != 0
    PyThread_tss_delete(&tss_key)
    after_delete = PyThread_tss_is_created(&tss_key) != 0
    return (after_create, after_delete)

def tss_alloc_free():
    """
    >>> tss_alloc_free()
    (True, False)
    """
    cdef Py_tss_t *ptr_key
    cdef bint after_alloc, after_free
    ptr_key = PyThread_tss_alloc()
    if ptr_key == NULL:
        # handle key allocation failure
        pass
    after_alloc = PyThread_tss_is_created(ptr_key) != 0
    PyThread_tss_free(ptr_key)
    after_free = PyThread_tss_is_created(ptr_key) != 0
    return (after_alloc, after_free)

def tss_set_get():
    """
    >>> tss_set_get()
    1
    """
    cdef Py_tss_t tss_key = Py_tss_NEEDS_INIT
    cdef int the_value = 1
    cdef int ret_value
    if PyThread_tss_create(&tss_key) > 0:
        # handle key creation failure
        pass
    if PyThread_tss_get(&tss_key) == NULL:
        PyThread_tss_set(&tss_key, <void *>&the_value)
    ret_value = (<int *>PyThread_tss_get(&tss_key))[0]
    PyThread_tss_delete(&tss_key)
    return ret_value<commit_msg>Repair and extend TSS API test.<commit_after># mode: run

from cpython.pythread cimport *


def tss_create_delete():
    """
    >>> tss_create_delete()
    (True, False)
    """
    cdef Py_tss_t tss_key = Py_tss_NEEDS_INIT
    cdef bint after_create, after_delete
    if PyThread_tss_create(&tss_key) != 0:
        raise MemoryError()
    after_create = PyThread_tss_is_created(&tss_key) != 0
    PyThread_tss_delete(&tss_key)
    after_delete = PyThread_tss_is_created(&tss_key) != 0
    return (after_create, after_delete)


def tss_alloc_free():
    """
    >>> tss_alloc_free()
    False
    """
    cdef Py_tss_t *ptr_key
    cdef bint after_alloc, after_free
    ptr_key = PyThread_tss_alloc()
    if ptr_key == NULL:
        raise MemoryError()
    after_alloc = PyThread_tss_is_created(ptr_key) != 0
    PyThread_tss_free(ptr_key)
    return after_alloc


def tss_alloc_create_delete_free():
    """
    >>> tss_alloc_create_delete_free()
    (False, True, False)
    """
    cdef Py_tss_t *ptr_key
    cdef bint after_alloc, after_free
    ptr_key = PyThread_tss_alloc()
    if ptr_key == NULL:
        raise MemoryError()
    after_alloc = PyThread_tss_is_created(ptr_key) != 0
    if PyThread_tss_create(ptr_key) != 0:
        raise MemoryError()
    after_create = PyThread_tss_is_created(ptr_key) != 0
    PyThread_tss_delete(ptr_key)
    after_delete = PyThread_tss_is_created(ptr_key) != 0
    PyThread_tss_free(ptr_key)
    return (after_alloc, after_create, after_delete)


def tss_set_get():
    """
    >>> tss_set_get()
    1
    """
    cdef Py_tss_t tss_key = Py_tss_NEEDS_INIT
    cdef int the_value = 1
    cdef int ret_value
    if PyThread_tss_create(&tss_key) != 0:
        raise MemoryError()
    if PyThread_tss_get(&tss_key) == NULL:
        PyThread_tss_set(&tss_key, <void *>&the_value)
    ret_value = (<int *>PyThread_tss_get(&tss_key))[0]
    PyThread_tss_delete(&tss_key)
    return ret_value
{'fraction_non_alphanumeric': 0.09976176295413937, 'fraction_numerical': 0.006253722453841573, 'mean_word_length': 3.4139290407358738, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 30, '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': '7203243', 'n_tokens_mistral': 1318, 'n_tokens_neox': 1294, 'n_words': 238}