2424import string
2525from array import array
2626import types
27- import new
2827
2928# Xlib modules
30- from Xlib import X
31- from Xlib .support import lock
29+ from .. import X
30+ from . .support import lock
3231
3332
3433class BadDataError (Exception ): pass
@@ -52,17 +51,17 @@ class BadDataError(Exception): pass
5251for c in 'bhil' :
5352 size = array (c ).itemsize
5453
55- array_unsigned_codes [size ] = string .upper (c )
54+ array_unsigned_codes [size ] = c .upper ()
5655 try :
5756 struct_to_array_codes [signed_codes [size ]] = c
58- struct_to_array_codes [unsigned_codes [size ]] = string .upper (c )
57+ struct_to_array_codes [unsigned_codes [size ]] = c .upper ()
5958 except KeyError :
6059 pass
6160
6261# print array_unsigned_codes, struct_to_array_codes
6362
6463
65- class Field :
64+ class Field ( object ) :
6665 """Field objects represent the data fields of a Struct.
6766
6867 Field objects must have the following attributes:
@@ -829,7 +828,7 @@ def parse_binary_value(self, data, display, length, format):
829828# Struct is also usable.
830829#
831830
832- class ScalarObj :
831+ class ScalarObj ( object ) :
833832 def __init__ (self , code ):
834833 self .structcode = code
835834 self .structvalues = 1
@@ -840,7 +839,7 @@ def __init__(self, code):
840839Card16Obj = ScalarObj ('H' )
841840Card32Obj = ScalarObj ('L' )
842841
843- class ResourceObj :
842+ class ResourceObj ( object ) :
844843 structcode = 'L'
845844 structvalues = 1
846845
@@ -860,7 +859,7 @@ def parse_value(self, value, display):
860859WindowObj = ResourceObj ('window' )
861860ColormapObj = ResourceObj ('colormap' )
862861
863- class StrClass :
862+ class StrClass ( object ) :
864863 structcode = None
865864
866865 def pack_value (self , val ):
@@ -873,7 +872,7 @@ def parse_binary(self, data, display):
873872Str = StrClass ()
874873
875874
876- class Struct :
875+ class Struct ( object ) :
877876
878877 """Struct objects represents a binary data structure. It can
879878 contain both fields with static and dynamic sizes. However, all
@@ -1096,8 +1095,8 @@ def to_binary(self, *varargs, **keys):
10961095 # memory leak isn't that serious. Besides, Python 2.0 has
10971096 # real garbage collect.
10981097
1099- exec code
1100- self .to_binary = new . instancemethod (to_binary , self , self .__class__ )
1098+ exec ( code )
1099+ self .to_binary = types . MethodType (to_binary , self , self .__class__ )
11011100
11021101 # Finally call it manually
11031102 return apply (self .to_binary , varargs , keys )
@@ -1181,8 +1180,8 @@ def parse_value(self, val, display, rawdict = 0):
11811180
11821181 # Finally, compile function as for to_binary.
11831182
1184- exec code
1185- self .parse_value = new . instancemethod (parse_value , self , self .__class__ )
1183+ exec ( code )
1184+ self .parse_value = types . MethodType (parse_value , self , self .__class__ )
11861185
11871186 # Call it manually
11881187 return self .parse_value (val , display , rawdict )
@@ -1285,8 +1284,8 @@ def parse_binary(self, data, display, rawdict = 0):
12851284
12861285 # Finally, compile function as for to_binary.
12871286
1288- exec code
1289- self .parse_binary = new . instancemethod (parse_binary , self , self .__class__ )
1287+ exec ( code )
1288+ self .parse_binary = types . MethodType (parse_binary , self , self .__class__ )
12901289
12911290 # Call it manually
12921291 return self .parse_binary (data , display , rawdict )
@@ -1412,7 +1411,7 @@ def __cmp__(self, other):
14121411 return cmp (self ._data , other )
14131412
14141413
1415- class Request :
1414+ class Request ( object ) :
14161415 def __init__ (self , display , onerror = None , * args , ** keys ):
14171416 self ._errorhandler = onerror
14181417 self ._binary = apply (self ._request .to_binary , args , keys )
0 commit comments