Apart from the bug, note that the scripts (there are by now many different ones in circulation) for calculating the band gap must not be treated as a black box. The definition of the band gap, as a concept, is complex enough that's it's nearly impossible to write a one-size-fits-all script for it - what you want, and what you get, depends on the situation. So, don't just trust what the script says - it might give you the indirect gap (which is as close as you can get to "the" band gap), or the direct one, or the direct at Gamma.
The DOS gap is probably the best approach to compute the indirect band gap, unless you know for a fact that it occurs on a high symmetry line, in which case you can use one of the scripts we have presented for it, as long as that line is included in the band structure calculation.