@@ -274,22 +274,28 @@ int cxoTransform_fromPython(cxoTransformNum transformNum,
274
274
case CXO_TRANSFORM_INT :
275
275
case CXO_TRANSFORM_DECIMAL :
276
276
case CXO_TRANSFORM_FLOAT :
277
- if (!PyFloat_Check (pyValue ) &&
277
+ if (PyBool_Check (pyValue )) {
278
+ buffer -> ptr = (pyValue == Py_True ) ? "1" : "0" ;
279
+ buffer -> size = 1 ;
280
+ buffer -> numCharacters = 1 ;
281
+ } else {
282
+ if (!PyFloat_Check (pyValue ) &&
278
283
#if PY_MAJOR_VERSION < 3
279
- !PyInt_Check (pyValue ) &&
284
+ !PyInt_Check (pyValue ) &&
280
285
#endif
281
- !PyLong_Check (pyValue ) &&
282
- !PyObject_TypeCheck (pyValue , cxoPyTypeDecimal )) {
283
- PyErr_SetString (PyExc_TypeError , "expecting number" );
284
- return -1 ;
286
+ !PyLong_Check (pyValue ) &&
287
+ !PyObject_TypeCheck (pyValue , cxoPyTypeDecimal )) {
288
+ PyErr_SetString (PyExc_TypeError , "expecting number" );
289
+ return -1 ;
290
+ }
291
+ textValue = PyObject_Str (pyValue );
292
+ if (!textValue )
293
+ return -1 ;
294
+ status = cxoBuffer_fromObject (buffer , textValue , encoding );
295
+ Py_DECREF (textValue );
296
+ if (status < 0 )
297
+ return -1 ;
285
298
}
286
- textValue = PyObject_Str (pyValue );
287
- if (!textValue )
288
- return -1 ;
289
- status = cxoBuffer_fromObject (buffer , textValue , encoding );
290
- Py_DECREF (textValue );
291
- if (status < 0 )
292
- return -1 ;
293
299
dbValue -> asBytes .ptr = (char * ) buffer -> ptr ;
294
300
dbValue -> asBytes .length = buffer -> size ;
295
301
return 0 ;
0 commit comments