2424if sys .version > '3' :
2525 _bchr = lambda x : bytes ([x ])
2626 _bord = lambda x : x [0 ]
27- from io import BytesIO
27+ from io import BytesIO as _BytesIO
2828else :
2929 _bchr = chr
3030 _bord = ord
31- from cStringIO import StringIO as BytesIO
31+ from cStringIO import StringIO as _BytesIO
3232
3333MAX_SIZE = 0x02000000
3434
@@ -102,7 +102,7 @@ def stream_deserialize(cls, f):
102102
103103 def serialize (self ):
104104 """Serialize, returning bytes"""
105- f = BytesIO ()
105+ f = _BytesIO ()
106106 self .stream_serialize (f )
107107 return f .getvalue ()
108108
@@ -115,7 +115,7 @@ def deserialize(cls, buf, allow_padding=False):
115115 If allow_padding is False and not all bytes are consumed during
116116 deserialization DeserializationExtraDataError will be raised.
117117 """
118- fd = BytesIO (buf )
118+ fd = _BytesIO (buf )
119119 r = cls .stream_deserialize (fd )
120120 if not allow_padding :
121121 padding = fd .read ()
@@ -186,13 +186,13 @@ def stream_deserialize(cls, f):
186186
187187 @classmethod
188188 def serialize (cls , obj ):
189- f = BytesIO ()
189+ f = _BytesIO ()
190190 cls .stream_serialize (obj , f )
191191 return f .getvalue ()
192192
193193 @classmethod
194194 def deserialize (cls , buf ):
195- return cls .stream_deserialize (BytesIO (buf ))
195+ return cls .stream_deserialize (_BytesIO (buf ))
196196
197197
198198class VarIntSerializer (Serializer ):
@@ -332,3 +332,24 @@ def uint256_from_compact(c):
332332def uint256_to_shortstr (u ):
333333 s = "%064x" % (u ,)
334334 return s [:16 ]
335+
336+
337+ __all__ = ('MAX_SIZE' ,
338+ 'Hash' ,
339+ 'Hash160' ,
340+ 'SerializationError' ,
341+ 'SerializationTruncationError' ,
342+ 'DeserializationExtraDataError' ,
343+ 'ser_read' ,
344+ 'Serializable' ,
345+ 'ImmutableSerializable' ,
346+ 'Serializer' ,
347+ 'VarIntSerializer' ,
348+ 'BytesSerializer' ,
349+ 'VectorSerializer' ,
350+ 'uint256VectorSerializer' ,
351+ 'intVectorSerialzer' ,
352+ 'VarStringSerializer' ,
353+ 'uint256_from_str' ,
354+ 'uint256_from_compact' ,
355+ 'uint256_to_shortstr' ,)
0 commit comments