MCPcopy Create free account
hub / github.com/pybind/pybind11 / conv

Function conv

tests/test_pytypes.cpp:29–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27bool check(PyObject *o) { return PyFloat_Check(o) != 0; }
28
29PyObject *conv(PyObject *o) {
30 PyObject *ret = nullptr;
31 if (PyLong_Check(o)) {
32 double v = PyLong_AsDouble(o);
33 if (!(v == -1.0 && PyErr_Occurred())) {
34 ret = PyFloat_FromDouble(v);
35 }
36 } else {
37 py::set_error(PyExc_TypeError, "Unexpected type");
38 }
39 return ret;
40}
41
42PyObject *default_constructed() { return PyFloat_FromDouble(0.0); }
43} // namespace detail

Callers

nothing calls this directly

Calls 1

set_errorFunction · 0.70

Tested by

no test coverage detected