[Zope3-checkins] CVS: Zope3/src/zope/interface - _zope_interface_ospec.c:1.7
Jim Fulton
jim@zope.com
Mon, 2 Jun 2003 07:07:43 -0400
Update of /cvs-repository/Zope3/src/zope/interface
In directory cvs.zope.org:/tmp/cvs-serv20352/src/zope/interface
Modified Files:
_zope_interface_ospec.c
Log Message:
Fixed a bug in handling of empty specifications.
Added a __nonzero__ implementation for object specifications,
=== Zope3/src/zope/interface/_zope_interface_ospec.c 1.6 => 1.7 ===
--- Zope3/src/zope/interface/_zope_interface_ospec.c:1.6 Sat May 31 18:12:17 2003
+++ Zope3/src/zope/interface/_zope_interface_ospec.c Mon Jun 2 07:07:41 2003
@@ -269,10 +269,14 @@
return NULL;
}
- if (sig == Py_None && psig != NULL)
+ if (psig != NULL && ! PyObject_IsTrue(psig))
+ {
+ Py_DECREF(psig);
+ psig = NULL;
+ }
+
+ if (sig != NULL && ! PyObject_IsTrue(sig))
{
- /* We have a provided sig, but the class sig was None, so make class
- sig NULL */
Py_DECREF(sig);
sig = NULL;
}
@@ -296,10 +300,7 @@
else if (psig != NULL)
return psig;
else
- {
- Py_INCREF(Py_None);
- return Py_None;
- }
+ return PyString_FromString("");
}
static PyGetSetDef OSpec_getset[] = {
@@ -366,9 +367,17 @@
return PyNumber_Subtract(v, w);
}
+static int
+OSpec_nonzero(OSpec *self)
+{
+ return PyObject_IsTrue(getspec(self));
+}
+
static PyNumberMethods OSpec_as_number = {
/* nb_add */ (binaryfunc)OSpec_add,
/* nb_subtract */ (binaryfunc)OSpec_sub,
+ /* nb_multiply to nb_absolute */ 0, 0, 0, 0, 0, 0, 0, 0,
+ /* nb_nonzero */ (inquiry)OSpec_nonzero,
};
static int