pyopenssl icon indicating copy to clipboard operation
pyopenssl copied to clipboard

bytearray is a bytes-like object

Open njsmith opened this issue 8 years ago • 2 comments

In [1]: from OpenSSL import SSL

In [2]: ctx = SSL.Context(SSL.SSLv23_METHOD)

In [3]: conn = SSL.Connection(ctx, None)

In [4]: conn.set_accept_state()

In [5]: conn.send(bytearray(10))
TypeError: data must be a memoryview, buffer or byte string

But bytearrays are nice and friendly and deserve your love too!

Actually I'd expect that it should accept anything that implements the buffer interface, using ffi.from_buffer.

njsmith avatar Apr 25 '17 08:04 njsmith

Realistically I think this probably does work with bytearray objects, and there's just a slightly overzealous isinstance check in front of the code.

Assuming that's true the fix is really easy. I'll quickly prototype that up to see if it works, and if it does I'll submit the patch.

Lukasa avatar Apr 25 '17 09:04 Lukasa

See #622.

Lukasa avatar Apr 25 '17 09:04 Lukasa