]> www.wagner.pp.ru Git - oss/ctypescrypto.git/blobdiff - ctypescrypto/bio.py
Fixes some style. Improved tests coverage for bio,oid,digest and cipher. Prepare...
[oss/ctypescrypto.git] / ctypescrypto / bio.py
index f8150f72cebc25db4b8604a33c88f6a1c64f727d..b1700b9a869ca80dd1eba7dba1c13117782202b0 100644 (file)
@@ -1,6 +1,9 @@
+"""
+Interface to OpenSSL BIO library
+"""
 from ctypescrypto import libcrypto
 from ctypes import c_char_p, c_void_p, c_int, string_at, c_long,POINTER,byref, create_string_buffer
-class Membio:
+class Membio(object):
        """ 
                Provides interface to OpenSSL memory bios 
                use str() or unicode() to get contents of writable bio
@@ -39,7 +42,7 @@ class Membio:
                @param length - if specifed, limits amount of data read. If not BIO is read until end of buffer
                """
                if not length is None:
-                       if type(length)!=type(0):
+                       if not isinstance(length,(int,long)):
                                raise TypeError("length to read should be number")
                        buf=create_string_buffer(length)
                        readbytes=libcrypto.BIO_read(self.bio,buf,length)
@@ -80,6 +83,8 @@ class Membio:
                Resets the read-only bio to start and discards all data from writable bio
                """
                libcrypto.BIO_ctrl(self.bio,1,0,None)
+
+__all__ = ['Membio']
 libcrypto.BIO_s_mem.restype=c_void_p
 libcrypto.BIO_new.restype=c_void_p
 libcrypto.BIO_new.argtypes=(c_void_p,)