From 593a47917a85e5632841f576ccc1c999196762e5 Mon Sep 17 00:00:00 2001 From: Icxolu <10486322+Icxolu@users.noreply.github.com> Date: Tue, 29 Oct 2024 18:32:39 +0100 Subject: [PATCH] apply review comments Co-authored-by: David Hewitt --- guide/src/class.md | 2 +- src/conversion.rs | 1 + tests/test_buffer_protocol.rs | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/guide/src/class.md b/guide/src/class.md index 814f540fcf5..6a80fd7ad9c 100644 --- a/guide/src/class.md +++ b/guide/src/class.md @@ -1290,7 +1290,7 @@ Python::with_gil(|py| { # .unwrap(); ``` -WARNING: `Py::new` and `.into_py` are currently inconsistent. Note how the constructed value is _not_ an instance of the specific variant. For this reason, constructing values is only recommended using `.into_py`. +WARNING: `Py::new` and `.into_pyobject` are currently inconsistent. Note how the constructed value is _not_ an instance of the specific variant. For this reason, constructing values is only recommended using `.into_pyobject`. ```rust # use pyo3::prelude::*; diff --git a/src/conversion.rs b/src/conversion.rs index 0622511a074..a280055cc7c 100644 --- a/src/conversion.rs +++ b/src/conversion.rs @@ -42,6 +42,7 @@ use std::convert::Infallible; /// # use pyo3::ffi; /// # /// Python::with_gil(|py| { +/// // ERROR: calling `.as_ptr()` will throw away the temporary object and leave `ptr` dangling. /// let ptr: *mut ffi::PyObject = 0xabad1dea_u32.into_pyobject(py)?.as_ptr(); /// /// let isnt_a_pystring = unsafe { diff --git a/tests/test_buffer_protocol.rs b/tests/test_buffer_protocol.rs index c271794d208..1f15e34b384 100644 --- a/tests/test_buffer_protocol.rs +++ b/tests/test_buffer_protocol.rs @@ -78,7 +78,7 @@ fn test_buffer_referenced() { .into_pyobject(py) .unwrap(); - let buf = PyBuffer::::get(instance.as_any()).unwrap(); + let buf = PyBuffer::::get(&instance).unwrap(); assert_eq!(buf.to_vec(py).unwrap(), input); drop(instance); buf