diff options
author | Žiga Seilnacht <ziga.seilnacht@gmail.com> | 2007-03-11 16:01:51 (GMT) |
---|---|---|
committer | Žiga Seilnacht <ziga.seilnacht@gmail.com> | 2007-03-11 16:01:51 (GMT) |
commit | ad3d2c2fe496c824292720e0c6f5265634503cb0 (patch) | |
tree | ebeaa30505a4e76083ef879fbdb90408024912b2 /Objects | |
parent | d28d9c8221136a37e47eac569fd7a508c3c946e3 (diff) | |
download | cpython-ad3d2c2fe496c824292720e0c6f5265634503cb0.zip cpython-ad3d2c2fe496c824292720e0c6f5265634503cb0.tar.gz cpython-ad3d2c2fe496c824292720e0c6f5265634503cb0.tar.bz2 |
Patch #1675981: remove unreachable code from type.__new__() method.
__dict__ and __weakref__ are removed from the slots tuple earlier
in the code, in the loop that mangles slot names.
(backport from rev. 54270)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/typeobject.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index c4a20fd..4f27402 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1935,13 +1935,11 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds) PyTuple_GET_ITEM(slots, i)); mp->type = T_OBJECT_EX; mp->offset = slotoffset; - if (base->tp_weaklistoffset == 0 && - strcmp(mp->name, "__weakref__") == 0) { - add_weak++; - mp->type = T_OBJECT; - mp->flags = READONLY; - type->tp_weaklistoffset = slotoffset; - } + + /* __dict__ and __weakref__ are already filtered out */ + assert(strcmp(mp->name, "__dict__") != 0); + assert(strcmp(mp->name, "__weakref__") != 0); + slotoffset += sizeof(PyObject *); } } |