Index: src/pycorba-object.c
===================================================================
--- src/pycorba-object.c	(revision 155)
+++ src/pycorba-object.c	(working copy)
@@ -28,8 +28,11 @@
 static void
 pycorba_object_dealloc(PyCORBA_Object *self)
 {
+	if (self->in_weakreflist != NULL)
+		PyObject_ClearWeakRefs((PyObject *) self);
+
     if (self->objref)
-	CORBA_Object_release(self->objref, NULL);
+    CORBA_Object_release(self->objref, NULL);
     self->objref = NULL;
 
     if (self->ob_type->tp_free)
@@ -297,7 +300,7 @@
     (traverseproc)0,                    /* tp_traverse */
     (inquiry)0,                         /* tp_clear */
     (richcmpfunc)0,                     /* tp_richcompare */
-    0,                                  /* tp_weaklistoffset */
+    offsetof(PyCORBA_Object, in_weakreflist), /* tp_weaklistoffset */
     (getiterfunc)0,                     /* tp_iter */
     (iternextfunc)0,                    /* tp_iternext */
     pycorba_object_methods,             /* tp_methods */
@@ -337,6 +340,7 @@
 
     args = PyTuple_New(0);
     self = (PyCORBA_Object *)stub->tp_new(stub, args, NULL);
+    self->in_weakreflist = NULL;
     Py_DECREF(args);
     if (!self)
 	return NULL;
Index: src/pyorbit.h
===================================================================
--- src/pyorbit.h	(revision 155)
+++ src/pyorbit.h	(working copy)
@@ -26,6 +26,7 @@
 typedef struct {
     PyObject_HEAD
     CORBA_Object objref;
+    PyObject    *in_weakreflist;
 } PyCORBA_Object;
 
 typedef struct {
