# Path: paramiko/py3compat.py
# def byte_chr(c):
#     assert isinstance(c, int)
#     return struct.pack("B", c)
# 
# PY2 = sys.version_info[0] < 3
# 
# class long(int):
#     pass
# 
# def b(s, encoding="utf8"):  # NOQA
#     """cast unicode or bytes to bytes"""
#     if isinstance(s, str):
#         return s
#     elif isinstance(s, unicode):  # NOQA
#         return s.encode(encoding)
#     elif isinstance(s, buffer):  # NOQA
#         return s
#     else:
#         raise TypeError("Expected unicode or bytes, got {!r}".format(s))


import logging
from paramiko.py3compat import byte_chr, PY2, long, b
(
    DISCONNECT_SERVICE_NOT_AVAILABLE,
    DISCONNECT_AUTH_CANCELLED_BY_USER,
    DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE,
) = (7, 13, 14)

zero_byte = byte_chr(0)
one_byte = byte_chr(1)
four_byte = byte_chr(4)
max_byte = byte_chr(0xff)
cr_byte = byte_chr(13)
linefeed_byte = byte_chr(10)
crlf = cr_byte + linefeed_byte

if PY2:
    cr_byte_value = cr_byte
    linefeed_byte_value = linefeed_byte
else:
    cr_byte_value = 13
    linefeed_byte_value = 10


def asbytes(s):
    """
    Coerce to bytes if possible or return unchanged.
    """
    try:
        # Attempt to run through our version of b(), which does the Right Thing
        # for string/unicode/buffer (Py2) or bytes/str (Py3), and raises
        # TypeError if it's not one of those types.

# Path: paramiko/py3compat.py
# def byte_chr(c):
#     assert isinstance(c, int)
#     return struct.pack("B", c)
# 
# PY2 = sys.version_info[0] < 3
# 
# class long(int):
#     pass
# 
# def b(s, encoding="utf8"):  # NOQA
#     """cast unicode or bytes to bytes"""
#     if isinstance(s, str):
#         return s
#     elif isinstance(s, unicode):  # NOQA
#         return s.encode(encoding)
#     elif isinstance(s, buffer):  # NOQA
#         return s
#     else:
#         raise TypeError("Expected unicode or bytes, got {!r}".format(s))


# Path: paramiko/common.py
import logging
from paramiko.py3compat import byte_chr, PY2, long, b

(
    DISCONNECT_SERVICE_NOT_AVAILABLE,
    DISCONNECT_AUTH_CANCELLED_BY_USER,
    DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE,
) = (7, 13, 14)

zero_byte = byte_chr(0)
one_byte = byte_chr(1)
four_byte = byte_chr(4)
max_byte = byte_chr(0xff)
cr_byte = byte_chr(13)
linefeed_byte = byte_chr(10)
crlf = cr_byte + linefeed_byte

if PY2:
    cr_byte_value = cr_byte
    linefeed_byte_value = linefeed_byte
else:
    cr_byte_value = 13
    linefeed_byte_value = 10


def asbytes(s):
    """
    Coerce to bytes if possible or return unchanged.
    """
    try:
        # Attempt to run through our version of b(), which does the Right Thing
        # for string/unicode/buffer (Py2) or bytes/str (Py3), and raises
        # TypeError if it's not one of those types.

        return b(s)