In [1]: import app1.example In [2]: app1.example.fix_polygon() version = 2.2.9 GEOS_NOTICE: Hole lies outside shell at or near point 1000 1000 p1.valid = False p1.valid_reason = Hole lies outside shell[1000 1000] mp.geom_type = MultiPolygon mp.__class__ = GEOS_ERROR: Argument is not a Polygon --------------------------------------------------------------------------- GEOSException Traceback (most recent call last) in ----> 1 app1.example.fix_polygon() ~/work/holebug/h1/app1/example.py in fix_polygon() 15 print('mp.geom_type = {}'.format(mp.geom_type)) # MultiPolygon 16 print('mp.__class__ = {}'.format(mp.__class__)) # returns Polygon in 2.2 MultiPolygon in 1.11 ---> 17 print(len(mp)) # GESOEXception 18 19 ~/.virtualenvs/hole111/lib/python3.6/site-packages/django/contrib/gis/geos/polygon.py in __len__(self) 54 def __len__(self): 55 "Return the number of rings in this Polygon." ---> 56 return self.num_interior_rings + 1 57 58 @classmethod ~/.virtualenvs/hole111/lib/python3.6/site-packages/django/contrib/gis/geos/polygon.py in num_interior_rings(self) 149 "Return the number of interior rings." 150 # Getting the number of rings --> 151 return capi.get_nrings(self.ptr) 152 153 def _get_ext_ring(self): ~/.virtualenvs/hole111/lib/python3.6/site-packages/django/contrib/gis/geos/libgeos.py in __call__(self, *args, **kwargs) 153 154 def __call__(self, *args, **kwargs): --> 155 return self.func(*args, **kwargs) 156 157 @cached_property ~/.virtualenvs/hole111/lib/python3.6/site-packages/django/contrib/gis/geos/prototypes/threadsafe.py in __call__(self, *args) 45 # Call the threaded GEOS routine with the pointer of the context handle 46 # as the first argument. ---> 47 return self.cfunc(self.thread_context.handle.ptr, *args) 48 49 def __str__(self): ~/.virtualenvs/hole111/lib/python3.6/site-packages/django/contrib/gis/geos/prototypes/errcheck.py in check_minus_one(result, func, cargs) 37 "Error checking on routines that should not return -1." 38 if result == -1: ---> 39 raise GEOSException('Error encountered in GEOS C function "%s".' % func.__name__) 40 else: 41 return result GEOSException: Error encountered in GEOS C function "GEOSGetNumInteriorRings_r".