Ticket #12450: geosfree.diff

File geosfree.diff, 1.2 KB (added by Joel Watts, 14 years ago)

Replace explicit check for 3.1.0 with a try/except block

  • django/contrib/gis/geos/prototypes/errcheck.py

    diff --git a/django/contrib/gis/geos/prototypes/errcheck.py b/django/contrib/gis/geos/prototypes/errcheck.py
    index c5037c1..2af3dc4 100644
    a b  
    33"""
    44from ctypes import c_void_p, string_at, CDLL
    55from django.contrib.gis.geos.error import GEOSException
    6 from django.contrib.gis.geos.libgeos import lgeos, GEOS_VERSION
     6from django.contrib.gis.geos.libgeos import lgeos
    77
    88# Getting the `free` routine used to free the memory allocated for
    99# string pointers returned by GEOS.
    10 if GEOS_VERSION >= (3, 1, 0):
    11     # In versions 3.1 and above, `GEOSFree` was added to the C API
     10try:
     11    # In versions 3.1.1 and above, `GEOSFree` was added to the C API
    1212    # because `free` isn't always available on all platforms.
    1313    free = lgeos.GEOSFree
    14     free.argtypes = [c_void_p]
    15     free.restype = None
    16 else:
     14except AttributeError:
    1715    # Getting the `free` routine from the C library of the platform.
    1816    # The C library is obtained by passing None into `CDLL`.
    1917    libc = CDLL(None)
    2018    free = libc.free
     19else:
     20    free.argtypes = [c_void_p]
     21    free.restype = None
    2122
    2223### ctypes error checking routines ###
    2324def last_arg_byref(args):
Back to Top