Copying Bio-python to globplot to satisfy the dependency
[jabaws.git] / binaries / src / globplot / biopython-1.50 / Bio / csupport.c
1 /* Copyright 2002 by Jeffrey Chang.  All rights reserved.
2  * This code is part of the Biopython distribution and governed by its
3  * license.  Please see the LICENSE file that should have been included
4  * as part of this package.
5  *
6  * csupport.c
7  * Created 27 January 2002
8  *
9  * Miscellaneous useful C functions not to be exported as a python
10  * module.
11  *
12  */
13
14 #include "Python.h"
15
16
17 /* Return a PyNumber as a double.
18  * Raises a TypeError if I can't do it.
19  */
20 double PyNumber_AsDouble(PyObject *py_num)
21 {
22     double val;
23     PyObject *floatobj;
24
25     if((floatobj = PyNumber_Float(py_num)) == NULL)
26         return(0.0);
27     val = PyFloat_AsDouble(floatobj);
28     Py_DECREF(floatobj);
29     return val;
30 }