[Twisted-Python] Porting twisted.spread.banana to py3

Wolfgang Rohdewald wolfgang.kde at rohdewald.de
Fri Jul 3 22:48:49 MDT 2015


Am Freitag, 3. Juli 2015, 23:00:45 schrieb Jørn Lomax:
> I have found another issue I'm wondering a little how to handle. There 
> are places in the bana_test file that sys.maxint is used. This no longer 
> exists in python3, so how should it be handled. Should we make an 
> artificial maxint to use for python3. I might want to note that it is 
> not used for comparison, but to create an integer over a given size:

i5:~/tmp/twisted/twisted/test (spread-py3-7598) git show a0d35fa
commit a0d35fa912b055bd65fb76b597de1d64675711d8
Author: Wolfgang Rohdewald <wolfgang at rohdewald.de>
Date:   Sun Nov 2 18:50:54 2014 +0100

    twisted.test.test_banana: PY3 has no sys.maxint

diff --git a/twisted/test/test_banana.py b/twisted/test/test_banana.py
index e0504d0..c43bdc8 100644
--- a/twisted/test/test_banana.py
+++ b/twisted/test/test_banana.py
@@ -455,10 +455,11 @@ class BananaTestCase(BananaTestBase):
         Test feeding the data byte per byte to the receiver. Normally
         data is not split.
         """
+        maxint = sys.maxsize if _PY3 else sys.maxint
         foo = [1, 2, [3, 4], [30.5, 40.2], 5,
                [b"six", b"seven", [b"eight", 9]], [10],
                # TODO: currently the C implementation's a bit buggy...
-               sys.maxint * 3l, sys.maxint * 2l, sys.maxint * long(-2)]
+               maxint * long(3), maxint * long(2), maxint * long(-2)]
         self.enc.sendEncoded(foo)
         self.feed(self.io.getvalue())
         assert self.result == foo, "%s!=%s" % (repr(self.result), repr(foo))

-- 
Wolfgang




More information about the Twisted-Python mailing list