[Python-checkins] python/dist/src/Objects typeobject.c,2.155,2.156

rhettinger@users.sourceforge.net rhettinger@users.sourceforge.net
Thu, 20 Jun 2002 15:23:17 -0700


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

Modified Files:
	typeobject.c 
Log Message:
SF 569257 -- Name mangle double underscored variable names in __slots__.


Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.155
retrieving revision 2.156
diff -C2 -d -r2.155 -r2.156
*** typeobject.c	18 Jun 2002 16:44:14 -0000	2.155
--- typeobject.c	20 Jun 2002 22:23:14 -0000	2.156
***************
*** 1002,1006 ****
  	PyObject *name, *bases, *dict;
  	static char *kwlist[] = {"name", "bases", "dict", 0};
! 	PyObject *slots, *tmp;
  	PyTypeObject *type, *base, *tmptype, *winner;
  	etype *et;
--- 1002,1007 ----
  	PyObject *name, *bases, *dict;
  	static char *kwlist[] = {"name", "bases", "dict", 0};
! 	static char buffer[256];
! 	PyObject *slots, *tmp, *newslots;
  	PyTypeObject *type, *base, *tmptype, *winner;
  	etype *et;
***************
*** 1116,1119 ****
--- 1117,1139 ----
  			}
  		}
+ 
+ 		newslots = PyTuple_New(nslots);
+ 		if (newslots == NULL)
+ 			return NULL;
+ 		for (i = 0; i < nslots; i++) {
+ 			tmp = PyTuple_GET_ITEM(slots, i);
+ 			if (_Py_Mangle(PyString_AS_STRING(name),
+ 				PyString_AS_STRING(tmp),
+ 				buffer, sizeof(buffer)))
+ 			{
+ 				tmp = PyString_FromString(buffer);
+ 			} else {
+ 				Py_INCREF(tmp);
+ 			}
+ 			PyTuple_SET_ITEM(newslots, i, tmp);
+ 		}
+ 		Py_DECREF(slots);
+ 		slots = newslots;
+ 
  	}
  	if (slots != NULL) {