Add negative infinity support for Python->pg conversion

This commit is contained in:
Marti Raudsepp 2011-02-10 19:08:33 +02:00 committed by Daniele Varrazzo
parent 9e9c221637
commit 9cb72a38da

View File

@ -42,8 +42,12 @@ pfloat_getquoted(pfloatObject *self, PyObject *args)
double n = PyFloat_AsDouble(self->wrapped);
if (isnan(n))
rv = Bytes_FromString("'NaN'::float");
else if (isinf(n))
rv = Bytes_FromString("'Infinity'::float");
else if (isinf(n)) {
if (n > 0)
rv = Bytes_FromString("'Infinity'::float");
else
rv = Bytes_FromString("'-Infinity'::float");
}
else {
rv = PyObject_Repr(self->wrapped);