I'm having a really weird issue with a built-in Python3.8 object that I'm not sure how to get around.
I was able to isolate the issue in my script to the append method of bytearray()
. If I try to append any value that is between 32 and 126 to my bytearray
, instead of appending hexadecimal it appends some other seemingly arbitrary character. Instead of appending 32 as \x20
and 126 as \x7e
, it appends
and ~
respectively.
It still exhibits this behavior if I specify the hex I want to append as actual hex instead of using ints as well. I just happened to have spent the last three to four hours using this function and somehow avoided test cases that included any byte value between 32-126.
int
objects. These aren't arbitrary characters, they are characters that correspond to the unicode code point of the characters you see (basically, printable ascii characters will be represented as those characters when you printbytearray
/bytes
objects). This is just how these objects are represented.