@@ -59,34 +59,6 @@ class TLSAlert(TLSError):
5959
6060 pass
6161
62- _descriptionStr = {\
63- AlertDescription .close_notify : "close_notify" ,\
64- AlertDescription .unexpected_message : "unexpected_message" ,\
65- AlertDescription .bad_record_mac : "bad_record_mac" ,\
66- AlertDescription .decryption_failed : "decryption_failed" ,\
67- AlertDescription .record_overflow : "record_overflow" ,\
68- AlertDescription .decompression_failure : "decompression_failure" ,\
69- AlertDescription .handshake_failure : "handshake_failure" ,\
70- AlertDescription .no_certificate : "no certificate" ,\
71- AlertDescription .bad_certificate : "bad_certificate" ,\
72- AlertDescription .unsupported_certificate : "unsupported_certificate" ,\
73- AlertDescription .certificate_revoked : "certificate_revoked" ,\
74- AlertDescription .certificate_expired : "certificate_expired" ,\
75- AlertDescription .certificate_unknown : "certificate_unknown" ,\
76- AlertDescription .illegal_parameter : "illegal_parameter" ,\
77- AlertDescription .unknown_ca : "unknown_ca" ,\
78- AlertDescription .access_denied : "access_denied" ,\
79- AlertDescription .decode_error : "decode_error" ,\
80- AlertDescription .decrypt_error : "decrypt_error" ,\
81- AlertDescription .export_restriction : "export_restriction" ,\
82- AlertDescription .protocol_version : "protocol_version" ,\
83- AlertDescription .insufficient_security : "insufficient_security" ,\
84- AlertDescription .internal_error : "internal_error" ,\
85- AlertDescription .inappropriate_fallback : "inappropriate_fallback" ,\
86- AlertDescription .user_canceled : "user_canceled" ,\
87- AlertDescription .no_renegotiation : "no_renegotiation" ,\
88- AlertDescription .unknown_psk_identity : "unknown_psk_identity" }
89-
9062
9163class TLSLocalAlert (TLSAlert ):
9264 """A TLS alert has been signalled by the local implementation.
@@ -109,9 +81,7 @@ def __init__(self, alert, message=None):
10981 self .message = message
11082
11183 def __str__ (self ):
112- alertStr = TLSAlert ._descriptionStr .get (self .description )
113- if alertStr == None :
114- alertStr = str (self .description )
84+ alertStr = AlertDescription .toStr (self .description )
11585 if self .message :
11686 return alertStr + ": " + self .message
11787 else :
@@ -136,9 +106,7 @@ def __init__(self, alert):
136106 self .level = alert .level
137107
138108 def __str__ (self ):
139- alertStr = TLSAlert ._descriptionStr .get (self .description )
140- if alertStr == None :
141- alertStr = str (self .description )
109+ alertStr = AlertDescription .toStr (self .description )
142110 return alertStr
143111
144112
0 commit comments