[PYTHON DB-SIG] Re: New Oracledb module now available
Anthony Baxter
Anthony Baxter <arb@connect.com.au>
Tue, 25 Mar 1997 22:15:39 +1100
>>> I wrote
> Don't suppose you had a chance to look at the
> (d is of type dbiDate)
> if d:
> segfaults? I'm still waiting for our licenses for the Sun debugger to
> turn up so I can pound on this.
Well, here's the fix. It seems that you must define nb_nonzero for
anything with tp_as_number set. Objects/objects.c, line 411 in 1.4 source.
(no, I didn't know about it either)
My fix makes it so a dbiDate object is "true" if it's not 01/01/1970. An
alternate is to simply make it always "true", by make dt_nb_nonzero always
return 1. This is something that's not covered by the DB-SIG API.
Anthony
*** dbi.c.dist Tue Mar 25 21:47:06 1997
--- dbi.c Tue Mar 25 21:58:23 1997
***************
*** 127,132 ****
--- 127,134 ----
{ return delg(a)->nb_add(dbiValue(a),b); }
static PyObject* dt_nb_subtract(PyObject* a, PyObject* b)
{ return delg(a)->nb_subtract(dbiValue(a),b); }
+ static int dt_nb_nonzero(PyObject* a)
+ { return (delg(a)->nb_int(dbiValue(a)) != 0); }
static PyObject* dt_nb_int(PyObject* a)
{ return delg(a)->nb_int(dbiValue(a)); }
static PyObject* dt_nb_long(PyObject* a)
***************
*** 152,158 ****
0, /* nb_negative */
0, /* nb_positive */
0, /* nb_absolute */
! 0, /* nb_nonzero */
0, /* nb_invert */
0, /* nb_lshift */
0, /* nb_rshift */
--- 154,160 ----
0, /* nb_negative */
0, /* nb_positive */
0, /* nb_absolute */
! dt_nb_nonzero, /* nb_nonzero */
0, /* nb_invert */
0, /* nb_lshift */
0, /* nb_rshift */
_______________
DB-SIG - SIG on Tabular Databases in Python
send messages to: db-sig@python.org
administrivia to: db-sig-request@python.org
_______________