Ticket #21662: 21662.diff

File 21662.diff, 1.3 KB (added by Claude Paroz, 11 years ago)
  • django/contrib/gis/geos/prepared.py

    diff --git a/django/contrib/gis/geos/prepared.py b/django/contrib/gis/geos/prepared.py
    index a6a205d..d5b531b 100644
    a b class PreparedGeometry(GEOSBase):  
    1212    ptr_type = capi.PREPGEOM_PTR
    1313
    1414    def __init__(self, geom):
     15        # Keeping a reference to the original geometry object to prevent it
     16        # from being garbage collected which could then crash the prepared one
     17        # See #21662
     18        self._base_geom = geom
    1519        if not isinstance(geom, GEOSGeometry):
    1620            raise TypeError
    1721        self.ptr = capi.geos_prepare(geom.ptr)
  • django/contrib/gis/geos/tests/test_geos.py

    diff --git a/django/contrib/gis/geos/tests/test_geos.py b/django/contrib/gis/geos/tests/test_geos.py
    index 3f0ce06..9ce7e0d 100644
    a b class GEOSTest(unittest.TestCase, TestDataMixin):  
    10461046            self.assertEqual(mpoly.intersects(pnt), prep.intersects(pnt))
    10471047            self.assertEqual(c, prep.covers(pnt))
    10481048
     1049        # Original geometry deletion should not crash the prepared one (#21662)
     1050        del mpoly
     1051        self.assertTrue(prep.covers(Point(5, 5)))
     1052
    10491053    def test_line_merge(self):
    10501054        "Testing line merge support"
    10511055        ref_geoms = (fromstr('LINESTRING(1 1, 1 1, 3 3)'),
Back to Top