X-Git-Url: http://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=ctypescrypto%2Fexception.py;h=30c138e43aa5ba52651243267abe0cdf974244fa;hb=92df3e73921ba7b8756bfab1af4189dab7cc610e;hp=43ba6a0b5a8858402f5fc0902d5b596bb54f1bdb;hpb=5eb6b4548beeacbd191b9c49a9b6cb7acf339837;p=oss%2Fctypescrypto.git diff --git a/ctypescrypto/exception.py b/ctypescrypto/exception.py index 43ba6a0..30c138e 100644 --- a/ctypescrypto/exception.py +++ b/ctypescrypto/exception.py @@ -7,6 +7,15 @@ strings_loaded=False __all__ = ['LibCryptoError','clear_err_stack'] +def _check_null(s): + """ + Handle transparently NULL returned from error reporting functions + instead of strings + """ + if s is None: + return "" + return s + class LibCryptoError(Exception): """ Exception for libcrypto errors. Adds all the info, which can be @@ -21,9 +30,9 @@ class LibCryptoError(Exception): e=libcrypto.ERR_get_error() m = msg while e != 0: - m+="\n\t"+libcrypto.ERR_lib_error_string(e)+":"+\ - libcrypto.ERR_func_error_string(e)+":"+\ - libcrypto.ERR_reason_error_string(e) + m+="\n\t"+_check_null(libcrypto.ERR_lib_error_string(e))+":"+\ + _check_null(libcrypto.ERR_func_error_string(e))+":"+\ + _check_null(libcrypto.ERR_reason_error_string(e)) e=libcrypto.ERR_get_error() self.args=(m,)