[Python-checkins] python/dist/src/Objects classobject.c,2.163,2.164

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Tue, 29 Oct 2002 10:36:45 -0800


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

Modified Files:
	classobject.c 
Log Message:
Since properties are supported here, is possible that
instance_getattr2() raises an exception.  Fix all code that made this
assumption.

Backport candidate.


Index: classobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v
retrieving revision 2.163
retrieving revision 2.164
diff -C2 -d -r2.163 -r2.164
*** classobject.c	18 Oct 2002 14:15:33 -0000	2.163
--- classobject.c	29 Oct 2002 18:36:40 -0000	2.164
***************
*** 550,553 ****
--- 550,557 ----
  	init = instance_getattr2(inst, initstr);
  	if (init == NULL) {
+ 		if (PyErr_Occurred()) {
+ 			Py_DECREF(inst);
+ 			return NULL;
+ 		}
  		if ((arg != NULL && (!PyTuple_Check(arg) ||
  				     PyTuple_Size(arg) != 0))
***************
*** 695,699 ****
  	}
  	v = instance_getattr2(inst, name);
! 	if (v == NULL) {
  		PyErr_Format(PyExc_AttributeError,
  			     "%.50s instance has no attribute '%.400s'",
--- 699,703 ----
  	}
  	v = instance_getattr2(inst, name);
! 	if (v == NULL && !PyErr_Occurred()) {
  		PyErr_Format(PyExc_AttributeError,
  			     "%.50s instance has no attribute '%.400s'",
***************
*** 1810,1832 ****
  	   instance_getattr2 directly because it will not set an
  	   exception on failure. */
! 	if (((PyInstanceObject *)v)->in_class->cl_getattr == NULL) {
  		method = instance_getattr2((PyInstanceObject *)v,
  					   name_op[op]);
! 		if (method == NULL) {
! 			assert(!PyErr_Occurred());
! 			res = Py_NotImplemented;
! 			Py_INCREF(res);
! 			return res;
! 		}
! 	} else {
  		method = PyObject_GetAttr(v, name_op[op]);
! 		if (method == NULL) {
  			if (!PyErr_ExceptionMatches(PyExc_AttributeError))
  				return NULL;
  			PyErr_Clear();
- 			res = Py_NotImplemented;
- 			Py_INCREF(res);
- 			return res;
  		}
  	}
  
--- 1814,1831 ----
  	   instance_getattr2 directly because it will not set an
  	   exception on failure. */
! 	if (((PyInstanceObject *)v)->in_class->cl_getattr == NULL)
  		method = instance_getattr2((PyInstanceObject *)v,
  					   name_op[op]);
! 	else
  		method = PyObject_GetAttr(v, name_op[op]);
! 	if (method == NULL) {
! 		if (PyErr_Occurred()) {
  			if (!PyErr_ExceptionMatches(PyExc_AttributeError))
  				return NULL;
  			PyErr_Clear();
  		}
+ 		res = Py_NotImplemented;
+ 		Py_INCREF(res);
+ 		return res;
  	}