[Python-checkins] CVS: python/dist/src/Modules socketmodule.c,1.171,1.172

Jeremy Hylton jhylton@users.sourceforge.net
Wed, 10 Oct 2001 15:33:34 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv4370

Modified Files:
	socketmodule.c 
Log Message:
USe PyObject_SetString() instead of PyObject_SetObject() in newSSLObject().


Index: socketmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v
retrieving revision 1.171
retrieving revision 1.172
diff -C2 -d -r1.171 -r1.172
*** socketmodule.c	2001/10/10 03:37:05	1.171
--- socketmodule.c	2001/10/10 22:33:32	1.172
***************
*** 2499,2507 ****
  {
  	SSLObject *self;
! 	PyObject *error = NULL;
  
  	self = PyObject_New(SSLObject, &SSL_Type); /* Create new object */
  	if (self == NULL){
! 		error =  PyString_FromString("newSSLObject error");
  		goto fail;
  	}
--- 2499,2507 ----
  {
  	SSLObject *self;
! 	char *errstr = NULL;
  
  	self = PyObject_New(SSLObject, &SSL_Type); /* Create new object */
  	if (self == NULL){
! 		errstr = "newSSLObject error";
  		goto fail;
  	}
***************
*** 2515,2525 ****
  	self->ctx = SSL_CTX_new(SSLv23_method()); /* Set up context */
  	if (self->ctx == NULL) {
! 		error = PyString_FromString("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");
  		goto fail;
  	}
--- 2515,2524 ----
  	self->ctx = SSL_CTX_new(SSLv23_method()); /* Set up context */
  	if (self->ctx == NULL) {
! 		errstr = "SSL_CTX_new error";
  		goto fail;
  	}
  
  	if ((key_file && !cert_file) || (!key_file && cert_file)) {
! 		errstr = "Both the key & certificate files must be specified";
  		goto fail;
  	}
***************
*** 2528,2533 ****
  		if (SSL_CTX_use_PrivateKey_file(self->ctx, key_file,
  						SSL_FILETYPE_PEM) < 1) {
! 			error = PyString_FromString(
! 				"SSL_CTX_use_PrivateKey_file error");
  			goto fail;
  		}
--- 2527,2531 ----
  		if (SSL_CTX_use_PrivateKey_file(self->ctx, key_file,
  						SSL_FILETYPE_PEM) < 1) {
! 			errstr = "SSL_CTX_use_PrivateKey_file error";
  			goto fail;
  		}
***************
*** 2535,2540 ****
  		if (SSL_CTX_use_certificate_chain_file(self->ctx,
  						       cert_file) < 1) {
! 			error = PyString_FromString(
! 				"SSL_CTX_use_certificate_chain_file error");
  			goto fail;
  		}
--- 2533,2537 ----
  		if (SSL_CTX_use_certificate_chain_file(self->ctx,
  						       cert_file) < 1) {
! 			errstr = "SSL_CTX_use_certificate_chain_file error";
  			goto fail;
  		}
***************
*** 2550,2554 ****
  	/* XXX If SSL_connect() returns 0, it's also a failure. */
  	if ((SSL_connect(self->ssl)) == -1) {
! 		error = PyString_FromString("SSL_connect error");
  		goto fail;
  	}
--- 2547,2551 ----
  	/* XXX If SSL_connect() returns 0, it's also a failure. */
  	if ((SSL_connect(self->ssl)) == -1) {
! 		errstr = "SSL_connect error";
  		goto fail;
  	}
***************
*** 2565,2572 ****
  	return self;
   fail:
! 	if (error) {
! 		PyErr_SetObject(SSLErrorObject, error);
! 		Py_DECREF(error);
! 	}
  	Py_DECREF(self);
  	return NULL;
--- 2562,2567 ----
  	return self;
   fail:
! 	if (errstr)
! 		PyErr_SetString(SSLErrorObject, errstr);
  	Py_DECREF(self);
  	return NULL;