I feel like I am missing something trivial here:
I recently made the jump over to Python3 (Using PyDev in Eclipse).
I have a project that calculates entropy values, and contains the following bit of code:
data = b'NVGI\x19\x01\x10\x00'
seen = dict(((chr(x), 0) for x in range(0,256)))
for byte in data:
seen[byte]+=1
The binary string in data is much longer, but this is sufficient for demonstration purposes.
With python3 this code results in an KeyError. With python2.7 this works with no issues at all.
This is due to the fact that iterating over data returns an integer (78 in this case) while seen expects a character 'N' instead.
The curious thing is that in python2.7 the same code will produce the expected character 'N'.
I have for now band-aided this by doing:
seen[ord(byte)] += 1
Can someone please try and replicate this or tell me where I went wrong?