diff options
author | Žiga Seilnacht <ziga.seilnacht@gmail.com> | 2007-03-11 15:54:54 +0000 |
---|---|---|
committer | Žiga Seilnacht <ziga.seilnacht@gmail.com> | 2007-03-11 15:54:54 +0000 |
commit | 890320877658121d9def472ae0d7063b81fc3aed (patch) | |
tree | 02488ae2d25e14e50fe422d1dd56d15304036ecd | |
parent | b27831887f84c8ef9326453572e750cdf225edcc (diff) | |
download | cpython-git-890320877658121d9def472ae0d7063b81fc3aed.tar.gz |
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. Will backport.
-rw-r--r-- | Misc/NEWS | 2 | ||||
-rw-r--r-- | Objects/typeobject.c | 12 |
2 files changed, 7 insertions, 7 deletions
@@ -12,6 +12,8 @@ What's New in Python 2.6 alpha 1? Core and builtins ----------------- +- Patch #1675981: remove unreachable code from ``type.__new__()`` method. + - Patch #1491866: change the complex() constructor to allow parthensized forms. This means complex(repr(x)) now works instead of raising a ValueError. diff --git a/Objects/typeobject.c b/Objects/typeobject.c index c2ed4b5666..020a9bb646 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1997,13 +1997,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 *); } } |