MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / extract

Method extract

src/objects/none.rs:51–61  ·  view source on GitHub ↗
(py: Python, obj: &PyObject)

Source from the content-addressed store, hash-verified

49
50impl FromPyObject<'_> for PyNone {
51 fn extract(py: Python, obj: &PyObject) -> PyResult<Self> {
52 if *obj == py.None() {
53 Ok(PyNone)
54 } else {
55 let msg = format!("Expected None but received {}", obj.get_type(py).name(py));
56 Err(PyErr::new_lazy_init(
57 py.get_type::<exc::TypeError>(),
58 Some(msg.to_py_object(py).into_object()),
59 ))
60 }
61 }
62}

Callers

nothing calls this directly

Calls 3

NoneMethod · 0.80
into_objectMethod · 0.45
to_py_objectMethod · 0.45

Tested by

no test coverage detected