def check_geom(result, func, cargs):
    # OGR_G_Clone may return an integer, even though the
    # restype is set to c_void_p
    if isinstance(result, (int, long)):
        result = c_void_p(result)
    if not result: 
        raise OGRException('Invalid geometry pointer returned from "%s".' % func.__name__)
    return result
Checks a function that returns a geometry.
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.2/django/contrib/gis/gdal/prototypes/errcheck.py/check_geom