def py3k_bytes(b):
try:<EOL><INDENT>return b.tobytes()<EOL><DEDENT>except AttributeError:<EOL><INDENT>try:<EOL><INDENT>return b"<STR_LIT>".join(chr(x) for x in b)<EOL><DEDENT>except TypeError:<EOL><INDENT>return bytes(b)<EOL><DEDENT><DEDENT>
Emulate the py3k bytes() constructor.

    NOTE: This is only a best effort function.