[Twisted-Python] Fixes for Twisted bindings in M2Crypto

Craig Rodrigues rodrigc at crodrigues.org
Tue Jul 26 20:19:30 MDT 2016


On Tue, Jul 26, 2016 at 8:47 AM, Matěj Cepl <mcepl at cepl.eu> wrote:

>
> I believe I have fixed all I can do without actually understanding Twisted
> in
> https://gitlab.com/mcepl/m2crypto/commit/6cd5f87b31e50016ebb7e44f3f2ae46610bc24e0.
> So now, if Twisted is so transparent and perfectly understandable, could
> you please suggest, what I do wrong, that the test ends in the endless loop
> (https://travis-ci.org/mcepl/M2Crypto/builds/147175901)?
>
>

In your initial e-mail, it would have been useful if you could have
provided reproduction steps
for your problem.

Can you provide reproduction steps?

Since I wasn't sure, I took a guess.

I did the following inside a Python 3.6 virtual environment under OS X:

git clone https://gitlab.com/mcepl/m2crypto.git m2crypto_test
cd m2crypto_test
git checkout python3
python setup.py build --openssl=/usr/local/opt/openssl
python setup.py bdist
python setup.py develop

py.test -v -s -k test_twisted_wrapper tests/test_ssl.py

I was able to reproduce the problem with something looping around:

DEBUG:_encrypt:self.data = "b'GET / HTTP/1.0\n\n\r\n'"
DEBUG:_decrypt:self.encrypted = "b''"
DEBUG:_encrypt:self.data = "b'GET / HTTP/1.0\n\n\r\n'"
DEBUG:_decrypt:self.encrypted = "b''"
DEBUG:_encrypt:self.data = "b'GET / HTTP/1.0\n\n\r\n'"
DEBUG:_decrypt:self.encrypted = "b''"
DEBUG:_encrypt:self.data = "b'GET / HTTP/1.0\n\n\r\n'"
DEBUG:_decrypt:self.encrypted = "b''"

I took a look in the M2Crypto code which interfaces with
Twisted, and found that the dataReceived() loop was never terminating
because dataReceived() takes bytes, but the code was
comparing to an emptry str.  So, the loop was never terminating.

I fixed this and other problems, and now the test_twisted_wrapper
passes on Python 3.  I submitted this merge request:

https://gitlab.com/mcepl/m2crypto/merge_requests/3/commits


While I was looking at the code, I also saw that the make_certs.py
utility does not work on Python 3.

I fixed that, and submitted this merge request:

https://gitlab.com/mcepl/m2crypto/merge_requests/4/commits

--
Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20160726/ff9caa33/attachment-0001.html>


More information about the Twisted-Python mailing list