Ticket #25072: 25072.diff

File 25072.diff, 1.3 KB (added by Claude Paroz, 9 years ago)

Allow GDALRaster garbage collection

  • django/contrib/gis/gdal/raster/band.py

    diff --git a/django/contrib/gis/gdal/raster/band.py b/django/contrib/gis/gdal/raster/band.py
    index f1eb50e..19f39e7 100644
    a b  
     1import weakref
    12from ctypes import byref, c_int
    23
    34from django.contrib.gis.gdal.base import GDALBase
    class GDALBand(GDALBase):  
    1415    Wraps a GDAL raster band, needs to be obtained from a GDALRaster object.
    1516    """
    1617    def __init__(self, source, index):
    17         self.source = source
     18        self.source = weakref.proxy(source)
    1819        self._ptr = capi.get_ds_raster_band(source._ptr, index)
    1920
    2021    @property
  • tests/gis_tests/gdal_tests/test_raster.py

    diff --git a/tests/gis_tests/gdal_tests/test_raster.py b/tests/gis_tests/gdal_tests/test_raster.py
    index aabec06..057329e 100644
    a b class GDALBandTests(unittest.TestCase):  
    275275    def setUp(self):
    276276        self.rs_path = os.path.join(os.path.dirname(upath(__file__)),
    277277                               '../data/rasters/raster.tif')
    278         rs = GDALRaster(self.rs_path)
    279         self.band = rs.bands[0]
     278        self.rs = GDALRaster(self.rs_path)
     279        self.band = self.rs.bands[0]
    280280
    281281    def test_band_data(self):
    282282        self.assertEqual(self.band.width, 163)
Back to Top