[Zope-CVS] CVS: Packages/Spread - spreadmodule.c:1.7
Guido van Rossum
guido@python.org
Wed, 19 Dec 2001 23:09:24 -0500
Update of /cvs-repository/Packages/Spread
In directory cvs.zope.org:/tmp/cvs-serv6403
Modified Files:
spreadmodule.c
Log Message:
group_id_richcompare(): support Py_NE as well as Py_EQ.
new_membership_msg():
- Check return value of second PyTuple_New() call.
- DECREF the right object when _PyString_Resize() fails.
- Don't need to cast self to (PyObject *) as DECREF arg.
=== Packages/Spread/spreadmodule.c 1.6 => 1.7 ===
PyObject *res;
- if (!GroupId_Check(v) || !GroupId_Check(w) || op != Py_EQ) {
+ if (!GroupId_Check(v) || !GroupId_Check(w) ||
+ (op != Py_EQ && op != Py_NE)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
- if (SP_equal_group_ids(((GroupId *)v)->gid, ((GroupId *)w)->gid) == 0)
+ if (SP_equal_group_ids(((GroupId *)v)->gid, ((GroupId *)w)->gid) ==
+ (op == Py_NE))
res = Py_False;
else
res = Py_True;
@@ -167,33 +169,37 @@
self->extra = NULL;
self->group_id = (PyObject *)new_group_id(extra->gid);
if (self->group_id == NULL) {
- Py_DECREF((PyObject *) self);
+ Py_DECREF(self);
return NULL;
}
self->members = PyTuple_New(num_members);
if (self->members == NULL) {
- Py_DECREF((PyObject *) self);
+ Py_DECREF(self);
return NULL;
}
for (i = 0; i < num_members; ++i) {
PyObject *s = PyString_FromString(members[i]);
if (!s) {
- Py_DECREF((PyObject *) self);
+ Py_DECREF(self);
return NULL;
}
PyTuple_SET_ITEM(self->members, i, s);
}
self->extra = PyTuple_New(extra->num_members);
+ if (self->extra == NULL) {
+ Py_DECREF(self);
+ return NULL;
+ }
for (i = 0; i < extra->num_members; ++i) {
PyObject *s = PyString_FromStringAndSize(extra->members[i],
MAX_GROUP_NAME);
if (!s) {
- Py_DECREF((PyObject *) self);
+ Py_DECREF(self);
return NULL;
}
if (_PyString_Resize(&s, strlen(PyString_AS_STRING(s))) < 0) {
- Py_DECREF(self->extra);
+ Py_DECREF(self);
return NULL;
}
PyTuple_SET_ITEM(self->extra, i, s);
@@ -265,7 +271,7 @@
self->sender = NULL;
self->groups = PyTuple_New(num_groups);
if (self->groups == NULL) {
- Py_DECREF((PyObject *) self);
+ Py_DECREF(self);
return NULL;
}
for (i = 0; i < num_groups; ++i) {