예제 #1
0
def init():
    if not has_version(3, 3, 2):
        raise RuntimeError('Gamera >= 3.3.2 is required')
    sys.modules['numpy'] = None
    result = _init()
    test_image = Image((0, 0), (5, 5), RGB)
    test_string = test_image._to_raw_string()
    try:
        sys.getrefcount
    except AttributeError:
        return result
    refcount = sys.getrefcount(test_string)
    if refcount >= 3:  # no coverage
        # See: https://groups.yahoo.com/neo/groups/gamera-devel/conversations/topics/2068
        raise RuntimeError('Memory leak in Gamera')
    else:
        assert refcount == 2
    try:
        PIL.fromstring = PIL.frombytes
        # Gamera still uses fromstring(), which was deprecated,
        # and finally removed in Pillow 3.0.0.
        # https://pillow.readthedocs.io/en/3.0.x/releasenotes/3.0.0.html#deprecated-methods
    except AttributeError:
        pass
    return result
예제 #2
0
def init():
    if not has_version(3, 3, 2):
        raise RuntimeError('Gamera >= 3.3.2 is required')
    sys.modules['numpy'] = None
    result = _init()
    test_image = Image((0, 0), (5, 5), RGB)
    test_string = test_image._to_raw_string()
    refcount = sys.getrefcount(test_string)
    if refcount >= 3:  # no coverage
        # See: https://groups.yahoo.com/neo/groups/gamera-devel/conversations/topics/2068
        raise RuntimeError('Memory leak in Gamera')
    else:
        assert refcount == 2
    try:
        PIL.fromstring = PIL.frombytes
        # Gamera still uses fromstring(), which was deprecated,
        # and finally removed in Pillow 3.0.0.
        # https://pillow.readthedocs.io/en/3.0.x/releasenotes/3.0.0.html#deprecated-methods
    except AttributeError:
        pass
    return result