  import math
  from ctypes import byref, c_double, c_int, c_void_p
  
  from django.contrib.gis.gdal.base import GDALBase
  from django.contrib.gis.gdal.error import GDALException
  from django.contrib.gis.gdal.prototypes import raster as capi
 
</s> remove         result = smin.value, smax.value, smean.value, sstd.value

        # Check if band is empty (in that case, set all statistics to None)
        if any((math.isnan(val) for val in result)):
 </s> add         # Computation of statistics fails for empty bands.
        try:
            func(*stats_args)
            result = smin.value, smax.value, smean.value, sstd.value
        except GDALException: </s> remove             capi.get_band_statistics(*stats_args)
 </s> add             func = capi.get_band_statistics </s> remove             capi.compute_band_statistics(*stats_args)
 </s> add             func = capi.compute_band_statistics </s> remove     errcheck=False
 </s> add  </s> remove     errcheck=False
 </s> add 

  from ctypes import byref, c_double, c_int, c_void_p
  
  from django.contrib.gis.gdal.base import GDALBase
  from django.contrib.gis.gdal.error import GDALException
  from django.contrib.gis.gdal.prototypes import raster as capi
replace keep keep keep keep keep
 Refs #26592 -- Fixed band statistics for empty bands and GDAL 2.1 
django/contrib/gis/gdal/raster/band.py