MCPcopy Index your code
hub / github.com/RustPython/RustPython / has_tls_protocol

Function has_tls_protocol

Lib/test/test_ssl.py:168–186  ·  view source on GitHub ↗

Check if a TLS protocol is available and enabled :param protocol: enum ssl._SSLMethod member or name :return: bool

(protocol)

Source from the content-addressed store, hash-verified

166
167
168def has_tls_protocol(protocol):
169 """Check if a TLS protocol is available and enabled
170
171 :param protocol: enum ssl._SSLMethod member or name
172 :return: bool
173 """
174 if isinstance(protocol, str):
175 assert protocol.startswith('PROTOCOL_')
176 protocol = getattr(ssl, protocol, None)
177 if protocol is None:
178 return False
179 if protocol in {
180 ssl.PROTOCOL_TLS, ssl.PROTOCOL_TLS_SERVER,
181 ssl.PROTOCOL_TLS_CLIENT
182 }:
183 # auto-negotiate protocols are always available
184 return True
185 name = protocol.name
186 return has_tls_version(name[len('PROTOCOL_'):])
187
188
189@functools.lru_cache

Callers 5

test_constructorMethod · 0.85
test_min_max_versionMethod · 0.85
test_protocol_tlsv1_2Method · 0.85

Calls 5

isinstanceFunction · 0.85
getattrFunction · 0.85
has_tls_versionFunction · 0.85
lenFunction · 0.85
startswithMethod · 0.45

Tested by

no test coverage detected