Better epydoc support.

This commit is contained in:
Federico Di Gregorio 2005-10-18 05:29:42 +00:00
parent 7eda959258
commit 3168e7b95d
2 changed files with 22 additions and 5 deletions

View File

@ -1,5 +1,10 @@
2005-10-18 Federico Di Gregorio <fog@initd.org> 2005-10-18 Federico Di Gregorio <fog@initd.org>
* psycopg/typecast.c: temporary fix to typecasting objects to return
False for any comparaison except an integer in self.values (i.e., we
don't raise an exception anymore on a coerce error.) Epydoc is now
happy.
* psycopg/config.h: ZETA config.h patch from Charlie Clark. * psycopg/config.h: ZETA config.h patch from Charlie Clark.
* examples/threads.py: fixed small typo: psycopg -> psycopg2. * examples/threads.py: fixed small typo: psycopg -> psycopg2.

View File

@ -221,8 +221,12 @@ typecast_coerce(PyObject **pv, PyObject **pw)
return 0; return 0;
} }
} }
PyErr_SetString(PyExc_TypeError, "type coercion failed");
return -1; /* PyErr_SetString(PyExc_TypeError, "type coercion failed"); */
/* let's try to return None instead of raising an exception */
Py_INCREF(*pv);
Py_INCREF(*pw);
return 0;
} }
static PyNumberMethods typecastObject_as_number = { static PyNumberMethods typecastObject_as_number = {
@ -255,13 +259,21 @@ static PyNumberMethods typecastObject_as_number = {
/* object methods */ /* object methods */
static int static int
typecast_cmp(typecastObject *self, typecastObject *v) typecast_cmp(typecastObject *self, PyObject* obj)
{ {
typecastObject *v = NULL;
int res; int res;
if (PyObject_TypeCheck(obj, &typecastType)) {
v = (typecastObject*)obj;
}
else {
return 1;
}
if (PyObject_Length(v->values) > 1 && PyObject_Length(self->values) == 1) { if (PyObject_Length(v->values) > 1 && PyObject_Length(self->values) == 1) {
/* calls itself exchanging the args */ /* calls itself exchanging the args */
return typecast_cmp(v, self); return typecast_cmp(v, (PyObject*)self);
} }
res = PySequence_Contains(self->values, PyTuple_GET_ITEM(v->values, 0)); res = PySequence_Contains(self->values, PyTuple_GET_ITEM(v->values, 0));