# Buggy code
def maximum_fill_value(obj):
    """
    Return the minimum value that can be represented by the dtype of an object.

    This function is useful for calculating a fill value suitable for
    taking the maximum of an array with a given dtype.

    Parameters
    ----------
    obj : {ndarray, dtype}
        An object that can be queried for it's numeric type.

    Returns
    -------
    val : scalar
        The minimum representable value.

    Raises
    ------
    TypeError
        If `obj` isn't a suitable numeric type.

    See Also
    --------
    minimum_fill_value : The inverse function.
    set_fill_value : Set the filling value of a masked array.
    MaskedArray.fill_value : Return current fill value.

    Examples
    --------
    >>> import numpy.ma as ma
    >>> a = np.int8()
    >>> ma.maximum_fill_value(a)
    -128
    >>> a = np.int32()
    >>> ma.maximum_fill_value(a)
    -2147483648

    An array of numeric data can also be passed.

    >>> a = np.array([1, 2, 3], dtype=np.int8)
    >>> ma.maximum_fill_value(a)
    -128
    >>> a = np.array([1, 2, 3], dtype=np.float32)
    >>> ma.maximum_fill_value(a)
    -inf

    """
    errmsg = "Unsuitable type for calculating maximum."
    if hasattr(obj, "dtype"):
        return _recursive_extremum_fill_value(obj.dtype, max_filler)
    elif isinstance(obj, float):
        return max_filler[ntypes.typeDict["float_"]]
    elif isinstance(obj, int):
        return max_filler[ntypes.typeDict["int_"]]
    elif isinstance(obj, long):
        return max_filler[ntypes.typeDict["uint"]]
    elif isinstance(obj, np.dtype):
        return max_filler[obj]
    else:
        raise TypeError(errmsg)


# Traceback (TypeError)
In [32]: A = np.arange(100, dtype='i8').view("(4)i4,(4)i4")

In [33]: Am = np.ma.MaskedArray(A, np.zeros_like(A))

In [34]: Am.sort()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-34-9b8a457bb910> in <module>()
----> 1 Am.sort()

/home/users/gholl/venv/stable-3.5/lib/python3.5/site-packages/numpy/ma/core.py in sort(self, axis, kind, order, endwith, fill_value)
5417                 filler = fill_value
5418
-> 5419             sidx = self.filled(filler).argsort(axis=axis, kind=kind,
5420                                                order=order)
5421             # save meshgrid memory for 1d arrays

/home/users/gholl/venv/stable-3.5/lib/python3.5/site-packages/numpy/ma/core.py in filled(self, fill_value)
3625             fill_value = self.fill_value
3626         else:
-> 3627             fill_value = _check_fill_value(fill_value, self.dtype)
3628
3629         if self is masked_singleton:

/home/users/gholl/venv/stable-3.5/lib/python3.5/site-packages/numpy/ma/core.py in _check_fill_value(fill_value, ndtype)
428             descr = ndtype.descr
429             fill_value = np.asarray(fill_value, dtype=object)
--> 430             fill_value = np.array(_recursive_set_fill_value(fill_value, descr),
431                                   dtype=ndtype)
432     else:

/home/users/gholl/venv/stable-3.5/lib/python3.5/site-packages/numpy/ma/core.py in _recursive_set_fill_value(fillvalue, dtypedescr)
392             output_value.append(tuple(_recursive_set_fill_value(fval, cdtype)))
393         else:
--> 394             output_value.append(np.array(fval, dtype=cdtype).item())
395     return tuple(output_value)
396

TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

# Fixed code
def maximum_fill_value(obj):
    """
    Return the minimum value that can be represented by the dtype of an object.

    This function is useful for calculating a fill value suitable for
    taking the maximum of an array with a given dtype.

    Parameters
    ----------
    obj : ndarray, dtype or scalar
        An object that can be queried for it's numeric type.

    Returns
    -------
    val : scalar
        The minimum representable value.

    Raises
    ------
    TypeError
        If `obj` isn't a suitable numeric type.

    See Also
    --------
    minimum_fill_value : The inverse function.
    set_fill_value : Set the filling value of a masked array.
    MaskedArray.fill_value : Return current fill value.

    Examples
    --------
    >>> import numpy.ma as ma
    >>> a = np.int8()
    >>> ma.maximum_fill_value(a)
    -128
    >>> a = np.int32()
    >>> ma.maximum_fill_value(a)
    -2147483648

    An array of numeric data can also be passed.

    >>> a = np.array([1, 2, 3], dtype=np.int8)
    >>> ma.maximum_fill_value(a)
    -128
    >>> a = np.array([1, 2, 3], dtype=np.float32)
    >>> ma.maximum_fill_value(a)
    -inf

    """
    return _extremum_fill_value(obj, max_filler, "maximum")