[Python-checkins] CVS: python/dist/src/Python errors.c,2.44,2.45

Barry A. Warsaw python-dev@python.org
Tue, 2 May 2000 15:27:53 -0400 (EDT)


Update of /projects/cvsroot/python/dist/src/Python
In directory anthem:/home/bwarsaw/projects/python/Python

Modified Files:
	errors.c 
Log Message:
PyErr_GivenExceptionMatches(): Check for err==NULL and exc==NULL and
return 0 (exceptions don't match).  This means that if an ImportError
is raised because exceptions.py can't be imported, the interpreter
will exit "cleanly" with an error message instead of just core
dumping.

PyErr_SetFromErrnoWithFilename(), PyErr_SetFromWindowsErrWithFilename(): 
Don't test on Py_UseClassExceptionsFlag.


Index: errors.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Python/errors.c,v
retrieving revision 2.44
retrieving revision 2.45
diff -C2 -r2.44 -r2.45
*** errors.c	2000/03/02 13:55:01	2.44
--- errors.c	2000/05/02 19:27:51	2.45
***************
*** 126,129 ****
--- 126,133 ----
       PyObject *err, *exc;
  {
+ 	if (err == NULL || exc == NULL) {
+ 		/* maybe caused by "import exceptions" that failed early on */
+ 		return 0;
+ 	}
  	if (PyTuple_Check(exc)) {
  		int i, n;
***************
*** 332,336 ****
  	}
  #endif
! 	if (filename != NULL && Py_UseClassExceptionsFlag)
  		v = Py_BuildValue("(iss)", i, s, filename);
  	else
--- 336,340 ----
  	}
  #endif
! 	if (filename != NULL)
  		v = Py_BuildValue("(iss)", i, s, filename);
  	else
***************
*** 380,384 ****
  	while (len > 0 && (s[len-1] <= ' ' || s[len-1] == '.'))
  		s[--len] = '\0';
! 	if (filename != NULL && Py_UseClassExceptionsFlag)
  		v = Py_BuildValue("(iss)", err, s, filename);
  	else
--- 384,388 ----
  	while (len > 0 && (s[len-1] <= ' ' || s[len-1] == '.'))
  		s[--len] = '\0';
! 	if (filename != NULL)
  		v = Py_BuildValue("(iss)", err, s, filename);
  	else