'The supernet containing the current network.
Args:
prefixlen_diff: An integer, the amount the prefix length of
the network should be decreased by.  For example, given a
/24 network and a prefixlen_diff of 3, a supernet with a
/21 netmask is returned.
Returns:
An IPv4 network object.
Raises:
PrefixlenDiffInvalidError: If
self.prefixlen - prefixlen_diff < 0. I.e., you have a
negative prefix length.
ValueError: prefixlen_diff and new_prefix are both set or
new_prefix is a larger number than the current prefix
(larger number means a smaller network)'

def supernet(self, prefixlen_diff=1, new_prefix=None):

    if (self._prefixlen == 0):
        return self
    if (new_prefix is not None):
        if (new_prefix > self._prefixlen):
            raise ValueError('new    prefix    must    be    shorter')
        if (prefixlen_diff != 1):
            raise ValueError('cannot    set    prefixlen_diff    and    new_prefix')
        prefixlen_diff = (self._prefixlen - new_prefix)
    if ((self.prefixlen - prefixlen_diff) < 0):
        raise PrefixlenDiffInvalidError(('current    prefixlen    is    %d,    cannot    have    a    prefixlen_diff    of    %d' % (self.prefixlen, prefixlen_diff)))
    return IPNetwork(('%s/%s' % (str(self.network), str((self.prefixlen - prefixlen_diff)))), version=self._version)
