summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2002-06-20 22:23:15 (GMT)
committerRaymond Hettinger <python@rcn.com>2002-06-20 22:23:15 (GMT)
commit0ae0c076615934ed237b412464b49b58c60c0644 (patch)
tree207ecdd2c40c541dfaffb657a7e9b16d6bada6e1 /Objects
parent1d1e1dba12d48d6d93b09e4bd140962b4c110dfb (diff)
downloadcpython-0ae0c076615934ed237b412464b49b58c60c0644.zip
cpython-0ae0c076615934ed237b412464b49b58c60c0644.tar.gz
cpython-0ae0c076615934ed237b412464b49b58c60c0644.tar.bz2
SF 569257 -- Name mangle double underscored variable names in __slots__.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 7918af0..47613f5 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -1001,7 +1001,8 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
{
PyObject *name, *bases, *dict;
static char *kwlist[] = {"name", "bases", "dict", 0};
- PyObject *slots, *tmp;
+ static char buffer[256];
+ PyObject *slots, *tmp, *newslots;
PyTypeObject *type, *base, *tmptype, *winner;
etype *et;
PyMemberDef *mp;
@@ -1115,6 +1116,25 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
return NULL;
}
}
+
+ 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) {
/* See if *this* class defines __getstate__ */