Returns the stderr as a byte stream in a Py2/PY3 compatible manner

    Returns
    -------
    io.BytesIO
        Byte stream of stderr

def stderr():
    """
    Returns the stderr as a byte stream in a Py2/PY3 compatible manner

    Returns
    -------
    io.BytesIO
        Byte stream of stderr
    """

    # We write all of the data to stderr with bytes, typically io.BytesIO. stderr in Python2
    # accepts bytes but Python3 does not. This is due to a type change on the attribute. To keep
    # this consistent, we leave Python2 the same and get the .buffer attribute on stderr in Python3
    byte_stderr = sys.stderr

    if sys.version_info.major > 2:
        byte_stderr = sys.stderr.buffer  # pylint: disable=no-member

    return byte_stderr