code: def _overwrite_special_dates(midnight_utcs,
                               opens_or_closes,
                               special_opens_or_closes):
      
      # Short circuit when nothing to apply.
      if not len(special_opens_or_closes):
          return
  
      len_m, len_oc = len(midnight_utcs), len(opens_or_closes)
      if len_m != len_oc:
          raise ValueError(
              "Found misaligned dates while building calendar.\n"
              "Expected midnight_utcs to be the same length as open_or_closes,\n"
              "but len(midnight_utcs)=%d, len(open_or_closes)=%d" % len_m, len_oc
          )
  
      # Find the array indices corresponding to each special date.
      indexer = midnight_utcs.get_indexer(special_opens_or_closes.index)
  
      # -1 indicates that no corresponding entry was found.  If any -1s are
      # present, then we have special dates that doesn't correspond to any
      # trading day.
      if -1 in indexer:
          bad_dates = list(special_opens_or_closes[indexer == -1])
          raise ValueError("Special dates %s are not trading days." % bad_dates)
  
      # NOTE: This is a slightly dirty hack.  We're in-place overwriting the
      # internal data of an Index, which is conceptually immutable.  Since we're
      # maintaining sorting, this should be ok, but this is a good place to
      # sanity check if things start going haywire with calendar computations.
      opens_or_closes.values[indexer] = special_opens_or_closes.values
docs: Overwrite dates in open_or_closes with corresponding dates in
      special_opens_or_closes, using midnight_utcs for alignment.