summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Di Gregorio <fog@initd.org>2005-10-18 05:29:42 +0000
committerFederico Di Gregorio <fog@initd.org>2005-10-18 05:29:42 +0000
commit3168e7b95d2eceb165bef55cd8c8f6e05872b531 (patch)
tree67a09fcdf59d2a4fb37abd2a491764b2d3f97e0a
parent7eda959258a86fc9deb0bae05948d4c2a962ca02 (diff)
downloadpsycopg2-3168e7b95d2eceb165bef55cd8c8f6e05872b531.tar.gz
Better epydoc support.
-rw-r--r--ChangeLog5
-rw-r--r--psycopg/typecast.c22
2 files changed, 22 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index b8f3784..f56c681 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
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.
* examples/threads.py: fixed small typo: psycopg -> psycopg2.
diff --git a/psycopg/typecast.c b/psycopg/typecast.c
index 19bcf1f..7ab8bc5 100644
--- a/psycopg/typecast.c
+++ b/psycopg/typecast.c
@@ -221,8 +221,12 @@ typecast_coerce(PyObject **pv, PyObject **pw)
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 = {
@@ -255,13 +259,21 @@ static PyNumberMethods typecastObject_as_number = {
/* object methods */
static int
-typecast_cmp(typecastObject *self, typecastObject *v)
+typecast_cmp(typecastObject *self, PyObject* obj)
{
+ typecastObject *v = NULL;
int res;
-
+
+ if (PyObject_TypeCheck(obj, &typecastType)) {
+ v = (typecastObject*)obj;
+ }
+ else {
+ return 1;
+ }
+
if (PyObject_Length(v->values) > 1 && PyObject_Length(self->values) == 1) {
/* 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));