In Python 2, bytes is simply an alias for str, and thus has the argument semantics of the str constructor, whereas in Python 3, bytes has the same argument semantics as they bytearray constructor. It would be convenient to have a version independent function that would follow the bytearray constructor semantics for the immutable binary data type.