# 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
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)
    except TypeError:
        try:
            # If it wasn't a string/byte/buffer type object, try calling an
            # asbytes() method, which many of our internal classes implement.
            return s.asbytes()
        except AttributeError:
            # Finally, just do nothing & assume this object is sufficiently
            # byte-y or buffer-y that everything will work out (or that callers
            # are capable of handling whatever it is.)
            return s


xffffffff = long(0xffffffff)

# 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

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)
    except TypeError:
        try:
            # If it wasn't a string/byte/buffer type object, try calling an
            # asbytes() method, which many of our internal classes implement.
            return s.asbytes()
        except AttributeError:
            # Finally, just do nothing & assume this object is sufficiently
            # byte-y or buffer-y that everything will work out (or that callers
            # are capable of handling whatever it is.)
            return s


xffffffff = long(0xffffffff)

x80000000 = long(0x80000000)