[Python-checkins] python/dist/src/Python newcompile.c, 1.1.2.65, 1.1.2.66

nnorwitz at projects.sourceforge.net nnorwitz at projects.sourceforge.net
Tue Jan 27 14:14:36 EST 2004


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29504/Python
Modified Files:
 Tag: ast-branch
	newcompile.c 
Log Message:
Fix problem if two consts, 100 and 100L are stored.
Putting both into a dict overwrites the first.
Store the value and type, like in original compile.
Index: newcompile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/newcompile.c,v
retrieving revision 1.1.2.65
retrieving revision 1.1.2.66
diff -C2 -d -r1.1.2.65 -r1.1.2.66
*** newcompile.c	27 Jan 2004 19:05:43 -0000	1.1.2.65
--- newcompile.c	27 Jan 2004 19:14:33 -0000	1.1.2.66
***************
*** 258,262 ****
 {
 	int i, n;
! 	PyObject *v, *dict = PyDict_New();
 
 	n = PyList_Size(list);
--- 258,262 ----
 {
 	int i, n;
! 	PyObject *v, *k, *dict = PyDict_New();
 
 	n = PyList_Size(list);
***************
*** 267,271 ****
 			return NULL;
 		}
! 		if (PyDict_SetItem(dict, PyList_GET_ITEM(list, i), v) < 0) {
 			Py_DECREF(v);
 			Py_DECREF(dict);
--- 267,274 ----
 			return NULL;
 		}
! k = PyList_GET_ITEM(list, i);
! k = Py_BuildValue("(OO)", k, k->ob_type);
! 		if (k == NULL || PyDict_SetItem(dict, k, v) < 0) {
! 			Py_XDECREF(k);
 			Py_DECREF(v);
 			Py_DECREF(dict);
***************
*** 603,616 ****
 		 PyObject *o)
 {
! 	PyObject *v;
 	int arg;
 
! 	v = PyDict_GetItem(dict, o);
 	if (!v) {
 		arg = PyDict_Size(dict);
 		v = PyInt_FromLong(arg);
! 		if (!v)
 			return 0;
! 		if (PyDict_SetItem(dict, o, v) < 0) {
 			Py_DECREF(v);
 			return 0;
--- 606,628 ----
 		 PyObject *o)
 {
! 	PyObject *t, *v;
 	int arg;
 
! /* necessary to make sure types aren't coerced (e.g., int and long) */
! /* XXX should use: t = PyTuple_Pack(2, o, o->ob_type); */
! t = Py_BuildValue("(OO)", o, o->ob_type);
! if (t == NULL)
! return 0;
! 
! 	v = PyDict_GetItem(dict, t);
 	if (!v) {
 		arg = PyDict_Size(dict);
 		v = PyInt_FromLong(arg);
! 		if (!v) {
! 			Py_DECREF(t);
 			return 0;
! }
! 		if (PyDict_SetItem(dict, t, v) < 0) {
! 			Py_DECREF(t);
 			Py_DECREF(v);
 			return 0;
***************
*** 620,623 ****
--- 632,636 ----
 	else
 		arg = PyInt_AsLong(v);
+ 	Py_DECREF(t);
 	return compiler_addop_i(c, opcode, arg);
 }
***************
*** 2594,2597 ****
--- 2607,2611 ----
 	while (PyDict_Next(dict, &pos, &k, &v)) {
 		i = PyInt_AS_LONG(v);
+ k = PyTuple_GET_ITEM(k, 0);
 		Py_INCREF(k);
 		assert((i - offset) < size);


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /