Mercurial > cpython-lru_cache-weakref
diff Modules/socketmodule.c @ 20366:7bcaca653388 legacy-trunk
USe PyObject_SetString() instead of PyObject_SetObject() in newSSLObject().
| author | Jeremy Hylton <jeremy@alum.mit.edu> |
|---|---|
| date | Wed, 10 Oct 2001 22:33:32 +0000 |
| parents | 8a09c855f957 |
| children | 300b1d8bfa4d |
line wrap: on
line diff
--- a/Modules/socketmodule.c Wed Oct 10 22:03:27 2001 +0000 +++ b/Modules/socketmodule.c Wed Oct 10 22:33:32 2001 +0000 @@ -2498,11 +2498,11 @@ newSSLObject(PySocketSockObject *Sock, char *key_file, char *cert_file) { SSLObject *self; - PyObject *error = NULL; + char *errstr = NULL; self = PyObject_New(SSLObject, &SSL_Type); /* Create new object */ if (self == NULL){ - error = PyString_FromString("newSSLObject error"); + errstr = "newSSLObject error"; goto fail; } memset(self->server, '\0', sizeof(char) * 256); @@ -2514,28 +2514,25 @@ self->ctx = SSL_CTX_new(SSLv23_method()); /* Set up context */ if (self->ctx == NULL) { - error = PyString_FromString("SSL_CTX_new error"); + errstr = "SSL_CTX_new error"; goto fail; } if ((key_file && !cert_file) || (!key_file && cert_file)) { - error = PyString_FromString( - "Both the key & certificate files must be specified"); + errstr = "Both the key & certificate files must be specified"; goto fail; } if (key_file && cert_file) { if (SSL_CTX_use_PrivateKey_file(self->ctx, key_file, SSL_FILETYPE_PEM) < 1) { - error = PyString_FromString( - "SSL_CTX_use_PrivateKey_file error"); + errstr = "SSL_CTX_use_PrivateKey_file error"; goto fail; } if (SSL_CTX_use_certificate_chain_file(self->ctx, cert_file) < 1) { - error = PyString_FromString( - "SSL_CTX_use_certificate_chain_file error"); + errstr = "SSL_CTX_use_certificate_chain_file error"; goto fail; } } @@ -2549,7 +2546,7 @@ /* Actually negotiate SSL connection */ /* XXX If SSL_connect() returns 0, it's also a failure. */ if ((SSL_connect(self->ssl)) == -1) { - error = PyString_FromString("SSL_connect error"); + errstr = "SSL_connect error"; goto fail; } self->ssl->debug = 1; @@ -2564,10 +2561,8 @@ Py_INCREF(self->Socket); return self; fail: - if (error) { - PyErr_SetObject(SSLErrorObject, error); - Py_DECREF(error); - } + if (errstr) + PyErr_SetString(SSLErrorObject, errstr); Py_DECREF(self); return NULL; }
