diff --git a/CHANGELOG.md b/CHANGELOG.md index fa0f7af52e5..defe8cebedd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Correct FFI definitions `Py_SetProgramName` and `Py_SetPythonHome` to take `*const` argument instead of `*mut`. [#1021](https://github.com/PyO3/pyo3/pull/1021) - Rename `PyString::to_string` to `to_str`, change return type `Cow` to `&str`. [#1023](https://github.com/PyO3/pyo3/pull/1023) - Correct FFI definition `_PyLong_AsByteArray` `*mut c_uchar` argument instead of `*const c_uchar`. [#1029](https://github.com/PyO3/pyo3/pull/1029) +- `PyType::as_type_ptr` is no longer `unsafe`. [#1047](https://github.com/PyO3/pyo3/pull/1047) ### Removed - Remove `PyString::as_bytes`. [#1023](https://github.com/PyO3/pyo3/pull/1023) diff --git a/src/pycell.rs b/src/pycell.rs index 19f0d1995ab..1a74c6506e8 100644 --- a/src/pycell.rs +++ b/src/pycell.rs @@ -79,7 +79,7 @@ impl PySizedLayout for PyCellInner {} unsafe impl PyBorrowFlagLayout for PyCellInner {} impl PyCellInner { - unsafe fn get_ptr(&self) -> *mut T { + fn get_ptr(&self) -> *mut T { self.value.get() } fn get_borrow_flag(&self) -> BorrowFlag { diff --git a/src/types/any.rs b/src/types/any.rs index 76ddf089d91..5132183733a 100644 --- a/src/types/any.rs +++ b/src/types/any.rs @@ -484,7 +484,7 @@ mod test { let gil = Python::acquire_gil(); let py = gil.python(); let obj = py.eval("42", None, None).unwrap(); - assert_eq!(unsafe { obj.get_type().as_type_ptr() }, obj.get_type_ptr()) + assert_eq!(obj.get_type().as_type_ptr(), obj.get_type_ptr()) } #[test] diff --git a/src/types/typeobject.rs b/src/types/typeobject.rs index 5b80d39db71..25a70145514 100644 --- a/src/types/typeobject.rs +++ b/src/types/typeobject.rs @@ -24,7 +24,7 @@ impl PyType { /// Retrieves the underlying FFI pointer associated with this Python object. #[inline] - pub unsafe fn as_type_ptr(&self) -> *mut ffi::PyTypeObject { + pub fn as_type_ptr(&self) -> *mut ffi::PyTypeObject { self.as_ptr() as *mut ffi::PyTypeObject }