diff options
author | Alex Stapleton <alexs@prol.etari.at> | 2014-03-01 21:04:08 +0000 |
---|---|---|
committer | Alex Stapleton <alexs@prol.etari.at> | 2014-03-01 21:04:08 +0000 |
commit | 151cede33ca6e00a6ffd48851ca43d615e8920e4 (patch) | |
tree | 884598c6831434ea2f7b320cd7d7e0992d51747e | |
parent | 235d3ce2b7ae13cf94c97c00f5aa89c40bc6763c (diff) | |
download | cryptography-151cede33ca6e00a6ffd48851ca43d615e8920e4.tar.gz cryptography-151cede33ca6e00a6ffd48851ca43d615e8920e4.tar.bz2 cryptography-151cede33ca6e00a6ffd48851ca43d615e8920e4.zip |
Use a namedtuple to keep errors in
-rw-r--r-- | cryptography/hazmat/backends/openssl/backend.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py index b14ec2d9..318edec1 100644 --- a/cryptography/hazmat/backends/openssl/backend.py +++ b/cryptography/hazmat/backends/openssl/backend.py @@ -13,6 +13,7 @@ from __future__ import absolute_import, division, print_function +import collections import itertools from cryptography import utils @@ -34,6 +35,10 @@ from cryptography.hazmat.primitives.ciphers.modes import ( ) +_OpenSSLError = collections.namedtuple("_OpenSSLError", + ["code", "lib", "func", "reason"]) + + @utils.register_interface(CipherBackend) @utils.register_interface(HashBackend) @utils.register_interface(HMACBackend) @@ -239,14 +244,14 @@ class Backend(object): func = self._lib.ERR_GET_FUNC(code) reason = self._lib.ERR_GET_REASON(code) - errors.append((code, lib, func, reason)) + errors.append(_OpenSSLError(code, lib, func, reason)) return errors def _unknown_error(self, error): return InternalError( "Unknown error code {0} from OpenSSL, " "you should probably file a bug. {1}".format( - error[0], self._err_string(error[0]) + error.code, self._err_string(error.code) ) ) |