You cannot call bytes(obj) to get a simple representation of obj on Python 3! E.g. bytes(42) returns a byte string with 42 NUL characters instead of b'42'.