[Python-checkins] python/dist/src/Objects frameobject.c, 2.78, 2.79 object.c, 2.217, 2.218

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Fri Jul 2 02:41:09 EDT 2004


Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18086/Objects

Modified Files:
	frameobject.c object.c 
Log Message:
SF Bug #215126:  Over restricted type checking on eval() function

The builtin eval() function now accepts any mapping for the locals argument.
Time sensitive steps guarded by PyDict_CheckExact() to keep from slowing
down the normal case.  My timings so no measurable impact.



Index: frameobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/frameobject.c,v
retrieving revision 2.78
retrieving revision 2.79
diff -C2 -d -r2.78 -r2.79
*** frameobject.c	20 Mar 2004 21:10:27 -0000	2.78
--- frameobject.c	2 Jul 2004 06:41:06 -0000	2.79
***************
*** 545,549 ****
  #ifdef Py_DEBUG
  	if (code == NULL || globals == NULL || !PyDict_Check(globals) ||
! 	    (locals != NULL && !PyDict_Check(locals))) {
  		PyErr_BadInternalCall();
  		return NULL;
--- 545,549 ----
  #ifdef Py_DEBUG
  	if (code == NULL || globals == NULL || !PyDict_Check(globals) ||
! 	    (locals != NULL && !PyMapping_Check(locals))) {
  		PyErr_BadInternalCall();
  		return NULL;
***************
*** 689,697 ****
  			value = PyCell_GET(value);
  		if (value == NULL) {
! 			if (PyDict_DelItem(dict, key) != 0)
  				PyErr_Clear();
  		}
  		else {
! 			if (PyDict_SetItem(dict, key, value) != 0)
  				PyErr_Clear();
  		}
--- 689,697 ----
  			value = PyCell_GET(value);
  		if (value == NULL) {
! 			if (PyObject_DelItem(dict, key) != 0)
  				PyErr_Clear();
  		}
  		else {
! 			if (PyObject_SetItem(dict, key, value) != 0)
  				PyErr_Clear();
  		}
***************
*** 706,710 ****
  	for (j = nmap; --j >= 0; ) {
  		PyObject *key = PyTuple_GET_ITEM(map, j);
! 		PyObject *value = PyDict_GetItem(dict, key);
  		if (deref) {
  			if (value || clear) {
--- 706,712 ----
  	for (j = nmap; --j >= 0; ) {
  		PyObject *key = PyTuple_GET_ITEM(map, j);
! 		PyObject *value = PyObject_GetItem(dict, key);
! 		if (value == NULL)
! 			PyErr_Clear();
  		if (deref) {
  			if (value || clear) {
***************
*** 721,724 ****
--- 723,727 ----
  			}
  		}
+ 		Py_XDECREF(value);
  	}
  }
***************
*** 743,747 ****
  	}
  	map = f->f_code->co_varnames;
! 	if (!PyDict_Check(locals) || !PyTuple_Check(map))
  		return;
  	PyErr_Fetch(&error_type, &error_value, &error_traceback);
--- 746,750 ----
  	}
  	map = f->f_code->co_varnames;
! 	if (!PyTuple_Check(map))
  		return;
  	PyErr_Fetch(&error_type, &error_value, &error_traceback);
***************
*** 781,785 ****
  	if (locals == NULL)
  		return;
! 	if (!PyDict_Check(locals) || !PyTuple_Check(map))
  		return;
  	PyErr_Fetch(&error_type, &error_value, &error_traceback);
--- 784,788 ----
  	if (locals == NULL)
  		return;
! 	if (!PyTuple_Check(map))
  		return;
  	PyErr_Fetch(&error_type, &error_value, &error_traceback);

Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.217
retrieving revision 2.218
diff -C2 -d -r2.217 -r2.218
*** object.c	22 Apr 2004 17:23:49 -0000	2.217
--- object.c	2 Jul 2004 06:41:06 -0000	2.218
***************
*** 1622,1626 ****
  		if (locals == NULL)
  			goto error;
! 		result = PyDict_Keys(locals);
  		if (result == NULL)
  			goto error;
--- 1622,1626 ----
  		if (locals == NULL)
  			goto error;
! 		result = PyMapping_Keys(locals);
  		if (result == NULL)
  			goto error;




More information about the Python-checkins mailing list