              # Add additional argument to force computation if there is no
              # existing PAM file to take the values from.
              force = True
              stats_args.insert(2, c_int(force))
              capi.get_band_statistics(*stats_args)
  
          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> 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.compute_band_statistics(*stats_args)
 </s> add             func = capi.compute_band_statistics </s> remove     errcheck=False
 </s> add  </s> remove     errcheck=False
 </s> add  </s> remove import math
 </s> add 
            func = capi.get_band_statistics
              # Add additional argument to force computation if there is no
              # existing PAM file to take the values from.
              force = True
              stats_args.insert(2, c_int(force))
            func = capi.get_band_statistics
  
          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)):
keep keep keep keep 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