我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用asyncore._strerror()。
def handshake (self): if not self._handshaking: err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR) if err != 0: raise OSError(err, asyncore._strerror(err)) ssl_context = create_urllib3_context(ssl_version=resolve_ssl_version(None), cert_reqs=resolve_cert_reqs(None)) if self.ac_negotiate_http2: try: ssl_context.set_alpn_protocols (H2_PROTOCOLS) except AttributeError: ssl_context.set_npn_protocols (H2_PROTOCOLS) self.socket = ssl_context.wrap_socket (self.socket, do_handshake_on_connect = False, server_hostname = self.address [0]) self._handshaking = True try: self.socket.do_handshake () except ssl.SSLError as why: if why.args [0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): return False raise ssl.SSLError(why) try: self._proto = self.socket.selected_alpn_protocol() except (AttributeError, NotImplementedError): try: self._proto = self.socket.selected_npn_protocol() except (AttributeError, NotImplementedError): pass self._handshaked = True return True
def test_strerror(self): # refers to bug #8573 err = asyncore._strerror(errno.EPERM) if hasattr(os, 'strerror'): self.assertEqual(err, os.strerror(errno.EPERM)) err = asyncore._strerror(-1) self.assertTrue(err != "")