diff options
author | Jean-Paul Calderone <exarkun@twistedmatrix.com> | 2014-01-18 10:34:12 -0500 |
---|---|---|
committer | Jean-Paul Calderone <exarkun@twistedmatrix.com> | 2014-01-18 10:34:12 -0500 |
commit | de0754690e01202bb4bd7e47c529db87765fc805 (patch) | |
tree | d79b678191b605161cbb5c117d59156f91e3a5ea | |
parent | 87e525ac72a778301f478382afda8a11e3683f5e (diff) | |
download | pyopenssl-de0754690e01202bb4bd7e47c529db87765fc805.tar.gz |
Make error messages native strings again.
-rw-r--r-- | OpenSSL/_util.py | 9 | ||||
-rw-r--r-- | OpenSSL/test/test_crypto.py | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/OpenSSL/_util.py b/OpenSSL/_util.py index 7c606b9..baeecc6 100644 --- a/OpenSSL/_util.py +++ b/OpenSSL/_util.py @@ -6,15 +6,18 @@ ffi = binding.ffi lib = binding.lib def exception_from_error_queue(exceptionType): + def text(charp): + return native(ffi.string(charp)) + errors = [] while True: error = lib.ERR_get_error() if error == 0: break errors.append(( - ffi.string(lib.ERR_lib_error_string(error)), - ffi.string(lib.ERR_func_error_string(error)), - ffi.string(lib.ERR_reason_error_string(error)))) + text(lib.ERR_lib_error_string(error)), + text(lib.ERR_func_error_string(error)), + text(lib.ERR_reason_error_string(error)))) raise exceptionType(errors) diff --git a/OpenSSL/test/test_crypto.py b/OpenSSL/test/test_crypto.py index 51da99b..4e42f70 100644 --- a/OpenSSL/test/test_crypto.py +++ b/OpenSSL/test/test_crypto.py @@ -1941,7 +1941,7 @@ class PKCS12Tests(TestCase): """ passwd = 'whatever' e = self.assertRaises(Error, load_pkcs12, b'fruit loops', passwd) - self.assertEqual( e.args[0][0][0], b'asn1 encoding routines') + self.assertEqual( e.args[0][0][0], 'asn1 encoding routines') self.assertEqual( len(e.args[0][0]), 3) |