summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Include/objimpl.h6
-rw-r--r--Misc/NEWS6
-rw-r--r--Objects/classobject.c1
3 files changed, 8 insertions, 5 deletions
diff --git a/Include/objimpl.h b/Include/objimpl.h
index 4197bde..4aa38d5 100644
--- a/Include/objimpl.h
+++ b/Include/objimpl.h
@@ -167,11 +167,7 @@ extern DL_IMPORT(void) _PyObject_Del(PyObject *);
/* Macros trading binary compatibility for speed. See also pymem.h.
Note that these macros expect non-NULL object pointers.*/
#define PyObject_INIT(op, typeobj) \
- ((op)->ob_type = (typeobj), _Py_NewReference((PyObject *)(op)), \
- (PyType_SUPPORTS_WEAKREFS((typeobj)) \
- ? *(PyObject_GET_WEAKREFS_LISTPTR(op)) = NULL \
- : NULL), \
- (op))
+ ( (op)->ob_type = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
#define PyObject_INIT_VAR(op, typeobj, size) \
( (op)->ob_size = (size), PyObject_INIT((op), (typeobj)) )
diff --git a/Misc/NEWS b/Misc/NEWS
index a1cf72a..ac755a2 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -61,6 +61,12 @@ Python/C API
- Py_BuildValue() now has a "D" conversion to create a Python complex
number from a Py_complex C value.
+- Extensions types which support weak references must now set the
+ field allocated for the weak reference machinery to NULL themselves;
+ this is done to avoid the cost of checking each object for having a
+ weakly referencable type in PyObject_INIT(), since most types are
+ not weakly referencable.
+
Distutils
- the sdist command now writes a PKG-INFO file, as described in PEP 241,
diff --git a/Objects/classobject.c b/Objects/classobject.c
index 00cfdde..d7b4c1e 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -453,6 +453,7 @@ PyInstance_NewRaw(PyObject *klass, PyObject *dict)
Py_DECREF(dict);
return NULL;
}
+ inst->in_weakreflist = NULL;
Py_INCREF(klass);
inst->in_class = (PyClassObject *)klass;
inst->in_dict = dict;