Convert bytearray to bytes-like object April 3, 2024 by Tarik As Coldspeed put it in the comments, just pass a bytearray to a bytes call: bytes(my_ba)