[Twisted-Python] Netstring unit tests fail with Python 1.x

Tommi Virtanen tv at twistedmatrix.com
Sat Oct 6 17:41:40 EDT 2001


	Don't know if this is the right fix, but...

[tv at ki ~/work/twistedmatrix/Twisted]$ DISPLAY= PYTHONPATH=. ./bin/runtests
.....................E.E.................attached [twisted.test.test_pb.DummyPerspective]
.............Rebuilding Delayed Event Queue...
(rebuilding stale twisted.test.crash_test_dummy.X instance (do))
Rebuilt.
........Created New Participant: glyph
Created New Participant: sean
..............................correct
....
Time: 1.545s

!!!FAILURES!!!
Test Results

Run: 94 ; Failures: 0; Errors: 2
There were 2 errors:
1) twisted.test.test_protocols.NetstringReceiverTestCase.testBuffer
Traceback (innermost last):
  File "./twisted/test/test_protocols.py", line 127, in testBuffer
    a.dataReceived(s)
  File "./twisted/protocols/basic.py", line 89, in dataReceived
    self.doData()
  File "./twisted/protocols/basic.py", line 53, in doData
    buffer,self.__data = self.__data[:self.length],self.__data[self.length:]
TypeError: slice index must be int

2) twisted.test.test_protocols.NetstringReceiverTestCase.testSafe
Traceback (innermost last):
  File "./twisted/test/test_protocols.py", line 140, in testSafe
    r.dataReceived(s)
  File "./twisted/protocols/basic.py", line 122, in dataReceived
    NetstringReceiver.dataReceived(self, data)
  File "./twisted/protocols/basic.py", line 89, in dataReceived
    self.doData()
  File "./twisted/protocols/basic.py", line 53, in doData
    buffer,self.__data = self.__data[:self.length],self.__data[self.length:]
TypeError: slice index must be int

[tv at ki ~/work/twistedmatrix/Twisted]$ 




Index: basic.py
===================================================================
RCS file: /cvs/Twisted/twisted/protocols/basic.py,v
retrieving revision 1.10
diff -u -r1.10 basic.py
--- basic.py	2001/09/30 18:55:43	1.10
+++ basic.py	2001/10/06 21:39:05
@@ -77,7 +77,7 @@
                 raise NetstringParseError
         self.__data = self.__data[m.end():]
         if m.group(1):
-            self.length = self.length * (10**len(m.group(1))) + long(m.group(1))
+            self.length = self.length * (10**len(m.group(1))) + int(m.group(1))
         if m.group(2):
             self.__buffer = ''
             self.mode = DATA 




[tv at ki ~/work/twistedmatrix/Twisted]$ DISPLAY= PYTHONPATH=. ./bin/runtests
.......................................attached [twisted.test.test_pb.DummyPerspective]
.............Rebuilding Delayed Event Queue...
(rebuilding stale twisted.test.crash_test_dummy.X instance (do))
Rebuilt.
........Created New Participant: glyph
Created New Participant: sean
..............................correct
....
Time: 1.550s

OK (94 tests)
[tv at ki ~/work/twistedmatrix/Twisted]$ 

-- 
tv@{{hq.yok.utu,havoc,gaeshido}.fi,{debian,wanderer}.org,stonesoft.com}
double a,b=4,c;main(){for(;++a<2e6;c-=(b=-b)/a++);printf("%f\n",c);}





More information about the Twisted-Python mailing list