Twisted Agent Python 2 ->3 Porting Pitfalls

Thomas Westfeld <[email protected]> Mon, 20 May 2019 07:21:33 +0000
Newsgroups gmane.comp.python.twisted
Message-ID <[email protected]>
Dear all,

I just migrated some quite basic twisted code from Python 2.7 to Python 3. Everything worked quite nicely, the main issue was the correct handling of strings vs. bytes.

There was a mean error I made when using the Twisted Agent http client: I specified the method as a Unicode string, instead of using Agent.request(b'GET',b'http://whatever.com'). The mean thing is that the code does not produce any error. It connects to the server via TCP but then stops.

It is given correctly in the examples of the docs and also in the source code, but wouldn't it make things easier to make a type check in the request method if the method parameter is of type Unicode and raise an error?

Best regards,
Thomas Westfeld
_______________________________________________
Twisted-Python mailing list
[email protected]
https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python