I've been working to create a new plugin from scratch to help with our documentation. In the process, I found a bug that caused me to waste a reasonable amount of time. It is subtle.
In practice, payload is not bytes but is a java byte array. This deviation from the typehints was a PITA to find. isinstance indicates that the java type is neither bytes nor bytearray.
From looking at the plugin code, it looks like there are a number of other on_data methods with bytes indicated.
Is there any reason we can't actually pass in bytes?
Additionally, a small bit of code indicates that calling bytes() on something that is already bytes just returns bytes, so it should be safe to make a change that will not break users.
x = b'`1234'
print(type(x))
xx = bytes(x)
print( x == xx )
I've been working to create a new plugin from scratch to help with our documentation. In the process, I found a bug that caused me to waste a reasonable amount of time. It is subtle.
We have the signature:
In practice,
payload
is notbytes
but is a java byte array. This deviation from the typehints was a PITA to find.isinstance
indicates that the java type is neitherbytes
norbytearray
.From looking at the plugin code, it looks like there are a number of other
on_data
methods withbytes
indicated. Is there any reason we can't actually pass inbytes
?Additionally, a small bit of code indicates that calling
bytes()
on something that is alreadybytes
just returnsbytes
, so it should be safe to make a change that will not break users.