<commit_before>import pkgutil


def get_resource(name: str) -> bytes:
    b = pkgutil.get_data(__package__, name)
    if b is None:
        raise Exception("no such embedded resource: %s" % name)
    assert type(b) == bytes  # todo: remove this
    return b
<commit_msg>Fix get_resource error handling<commit_after>import pkgutil


def get_resource(name: str) -> bytes:
    try:
        b = pkgutil.get_data(__package__, name)
    except OSError:
        raise Exception("no such embedded resource: %s" % name) from None
    if b is None:
        raise Exception("package cannot be located or loaded: %s" % __package__)
    assert type(b) == bytes  # todo: remove this
    return b
{'fraction_non_alphanumeric': 0.09544787077826726, 'fraction_numerical': 0.0, 'mean_word_length': 3.2098765432098766, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5106382', 'n_tokens_mistral': 210, 'n_tokens_neox': 202, 'n_words': 74}