[Twisted-Python] Twisted Agent Python 2 ->3 Porting Pitfalls
![](https://secure.gravatar.com/avatar/c4daed4d9cc7df1188e9521b5d3a784d.jpg?s=120&d=mm&r=g)
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
![](https://secure.gravatar.com/avatar/bcb6ef473ff1644fddee1b4e7c730b01.jpg?s=120&d=mm&r=g)
This looks like a straightforward bug to me. I don't see any reason we can't change the implementation to either raise TypeError immediately or accept a string, since any code that passes a string doesn't work right now. Would you file a bug at https://twistedmatrix.com/trac/newticket? ---Tom -- Tom Most twm@freecog.net On Mon, May 20, 2019, at 12:22 AM, Thomas Westfeld wrote:
![](https://secure.gravatar.com/avatar/bcb6ef473ff1644fddee1b4e7c730b01.jpg?s=120&d=mm&r=g)
I filed https://twistedmatrix.com/trac/ticket/9643 and submitted a PR: https://github.com/twisted/twisted/pull/1146 ---Tom On Thu, May 23, 2019, at 11:50 PM, Glyph wrote:
![](https://secure.gravatar.com/avatar/c4daed4d9cc7df1188e9521b5d3a784d.jpg?s=120&d=mm&r=g)
Dear Tom, thanks for helping me out. I really appreciate it. Best regards, Thomas -----Original Message----- From: Twisted-Python [mailto:twisted-python-bounces@twistedmatrix.com] On Behalf Of Tom Most Sent: Monday, May 27, 2019 6:04 AM To: twisted-python@twistedmatrix.com Subject: Re: [Twisted-Python] Twisted Agent Python 2 ->3 Porting Pitfalls I filed https://twistedmatrix.com/trac/ticket/9643 and submitted a PR: https://github.com/twisted/twisted/pull/1146 ---Tom On Thu, May 23, 2019, at 11:50 PM, Glyph wrote:
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
![](https://secure.gravatar.com/avatar/bcb6ef473ff1644fddee1b4e7c730b01.jpg?s=120&d=mm&r=g)
This looks like a straightforward bug to me. I don't see any reason we can't change the implementation to either raise TypeError immediately or accept a string, since any code that passes a string doesn't work right now. Would you file a bug at https://twistedmatrix.com/trac/newticket? ---Tom -- Tom Most twm@freecog.net On Mon, May 20, 2019, at 12:22 AM, Thomas Westfeld wrote:
![](https://secure.gravatar.com/avatar/bcb6ef473ff1644fddee1b4e7c730b01.jpg?s=120&d=mm&r=g)
I filed https://twistedmatrix.com/trac/ticket/9643 and submitted a PR: https://github.com/twisted/twisted/pull/1146 ---Tom On Thu, May 23, 2019, at 11:50 PM, Glyph wrote:
![](https://secure.gravatar.com/avatar/c4daed4d9cc7df1188e9521b5d3a784d.jpg?s=120&d=mm&r=g)
Dear Tom, thanks for helping me out. I really appreciate it. Best regards, Thomas -----Original Message----- From: Twisted-Python [mailto:twisted-python-bounces@twistedmatrix.com] On Behalf Of Tom Most Sent: Monday, May 27, 2019 6:04 AM To: twisted-python@twistedmatrix.com Subject: Re: [Twisted-Python] Twisted Agent Python 2 ->3 Porting Pitfalls I filed https://twistedmatrix.com/trac/ticket/9643 and submitted a PR: https://github.com/twisted/twisted/pull/1146 ---Tom On Thu, May 23, 2019, at 11:50 PM, Glyph wrote:
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
participants (3)
-
Glyph
-
Thomas Westfeld
-
Tom Most