1111from foolscap .slicers .allslicers import RootSlicer , RootUnslicer
1212from foolscap .slicers .allslicers import ReplaceVocabSlicer , AddVocabSlicer
1313
14- from .util import long_type
1514from . import stringchain
1615from . import tokens
1716from .tokens import SIZE_LIMIT , STRING , LIST , INT , NEG , \
@@ -60,15 +59,15 @@ def bytes_to_long(s):
6059
6160 This is (essentially) the inverse of long_to_bytes().
6261 """
63- acc = long_type ( 0 )
62+ acc = 0
6463 for i in six .iterbytes (s ):
6564 acc <<= 8
6665 acc += i
6766 return acc
6867
6968HIGH_BIT_SET = b"\x80 "
7069
71- SIMPLE_TOKENS = six . integer_types + ( float , six . binary_type )
70+ SIMPLE_TOKENS = ( int , float , bytes )
7271
7372# Banana is a big class. It is split up into three sections: sending,
7473# receiving, and connection setup. These used to be separate classes, but
@@ -417,7 +416,7 @@ def outgoingVocabTableWasReplaced(self, newTable):
417416 # this is called by the ReplaceVocabSlicer to manipulate our table.
418417 # It must certainly *not* be called by higher-level user code.
419418 for k in newTable .keys ():
420- assert isinstance (k , six . binary_type )
419+ assert isinstance (k , bytes )
421420 self .outgoingVocabulary = newTable
422421 if newTable :
423422 maxIndex = max (newTable .values ()) + 1
@@ -466,7 +465,7 @@ def sendOpen(self):
466465
467466 def sendToken (self , obj ):
468467 write = self .transport .write
469- if isinstance (obj , six . integer_types ):
468+ if isinstance (obj , int ):
470469 if obj >= 2 ** 31 :
471470 s = long_to_bytes (obj )
472471 int2b128 (len (s ), write )
@@ -486,7 +485,7 @@ def sendToken(self, obj):
486485 elif isinstance (obj , float ):
487486 write (FLOAT )
488487 write (struct .pack ("!d" , obj ))
489- elif isinstance (obj , six . binary_type ):
488+ elif isinstance (obj , bytes ):
490489 if obj in self .outgoingVocabulary :
491490 symbolID = self .outgoingVocabulary [obj ]
492491 int2b128 (symbolID , write )
@@ -924,7 +923,7 @@ def handleData(self, chunk):
924923 elif typebyte == NEG :
925924 # -2**31 is too large for a positive int, so go through
926925 # LongType first
927- obj = int (- long_type (header ))
926+ obj = int (- int (header ))
928927 elif typebyte == LONGINT or typebyte == LONGNEG :
929928 strlen = header
930929 if len (self .buffer ) >= strlen :
0 commit comments