| 281 | template Status CIntFromPython(PyObject*, uint64_t*, const std::string&); |
| 282 | |
| 283 | inline bool MayHaveNaN(PyObject* obj) { |
| 284 | // Some core types can be very quickly type-checked and do not allow NaN values |
| 285 | const int64_t non_nan_tpflags = Py_TPFLAGS_LONG_SUBCLASS | Py_TPFLAGS_LIST_SUBCLASS | |
| 286 | Py_TPFLAGS_TUPLE_SUBCLASS | Py_TPFLAGS_BYTES_SUBCLASS | |
| 287 | Py_TPFLAGS_UNICODE_SUBCLASS | Py_TPFLAGS_DICT_SUBCLASS | |
| 288 | Py_TPFLAGS_BASE_EXC_SUBCLASS | Py_TPFLAGS_TYPE_SUBCLASS; |
| 289 | return !PyType_HasFeature(Py_TYPE(obj), non_nan_tpflags); |
| 290 | } |
| 291 | |
| 292 | bool PyFloat_IsNaN(PyObject* obj) { |
| 293 | return PyFloat_Check(obj) && std::isnan(PyFloat_AsDouble(obj)); |
no outgoing calls
no test coverage detected