2121import sys
2222import traceback
2323import struct
24- import string
2524from array import array
2625import types
2726
@@ -421,8 +420,8 @@ def __init__(self, name, pad = 1):
421420 self .pad = pad
422421
423422 def pack_value (self , val ):
424- # Convert 8-byte string into 16-byte list
425- if type (val ) is types . StringType :
423+ """ Convert 8-byte string into 16-byte list"""
424+ if type (val ) is bytes :
426425 val = map (lambda c : ord (c ), val )
427426
428427 slen = len (val )
@@ -533,7 +532,7 @@ def pack_value(self, val):
533532 for v in val :
534533 data .append (self .type .pack_value (v ))
535534
536- data = string .join (data , '' )
535+ data = '' .join (data )
537536
538537 if self .pad :
539538 dlen = len (data )
@@ -573,7 +572,7 @@ def pack_value(self, val):
573572 return self .type .pack_value (val )
574573
575574 def check_value (self , val ):
576- if type (val ) is types . TupleType :
575+ if type (val ) is tuple :
577576 vals = []
578577 i = 0
579578 for f in self .type .fields :
@@ -589,7 +588,7 @@ def check_value(self, val):
589588 i = i + 1
590589 return vals
591590
592- if type (val ) is types . DictType :
591+ if type (val ) is dict :
593592 data = val
594593 elif isinstance (val , DictWrapper ):
595594 data = val ._data
@@ -643,7 +642,7 @@ def pack_value(self, value):
643642 if fmt not in (8 , 16 , 32 ):
644643 raise BadDataError ('Invalid property data format %d' % fmt )
645644
646- if type (val ) is types . StringType :
645+ if type (val ) is bytes :
647646 size = fmt / 8
648647 vlen = len (val )
649648 if vlen % size :
@@ -655,7 +654,7 @@ def pack_value(self, value):
655654 dlen = vlen / size
656655
657656 else :
658- if type (val ) is types . TupleType :
657+ if type (val ) is tuple :
659658 val = list (val )
660659
661660 size = fmt / 8
@@ -1190,16 +1189,16 @@ def pack_value(self, value):
11901189
11911190 for v in value :
11921191 # Let values be simple strings, meaning a delta of 0
1193- if type (v ) is types . StringType :
1192+ if type (v ) is bytes :
11941193 v = (0 , v )
11951194
11961195 # A tuple, it should be (delta, string)
11971196 # Encode it as one or more textitems
11981197
1199- if type (v ) in (types . TupleType , types . DictType ) or \
1198+ if type (v ) in (tuple , dict ) or \
12001199 isinstance (v , DictWrapper ):
12011200
1202- if type (v ) is types . TupleType :
1201+ if type (v ) is tuple :
12031202 delta , str = v
12041203 else :
12051204 delta = v ['delta' ]
@@ -1391,7 +1390,7 @@ def __repr__(self):
13911390 val = val | 0x80
13921391 kwlist .append ('%s = %s' % (kw , repr (val )))
13931392
1394- kws = string . join ( kwlist , ', ' )
1393+ kws = ', ' . join ( kwlist )
13951394 return '%s(%s)' % (self .__class__ , kws )
13961395
13971396 def __cmp__ (self , other ):
0 commit comments