Skip to content

Commit

Permalink
Functions which cast reference to pointer are not unsafe.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Jul 17, 2020
1 parent d9d095c commit 3341d10
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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<str>` 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)
Expand Down
2 changes: 1 addition & 1 deletion src/pycell.rs
Expand Up @@ -79,7 +79,7 @@ impl<T: PyClass> PySizedLayout<T> for PyCellInner<T> {}
unsafe impl<T: PyClass> PyBorrowFlagLayout<T> for PyCellInner<T> {}

impl<T: PyClass> PyCellInner<T> {
unsafe fn get_ptr(&self) -> *mut T {
fn get_ptr(&self) -> *mut T {
self.value.get()
}
fn get_borrow_flag(&self) -> BorrowFlag {
Expand Down
2 changes: 1 addition & 1 deletion src/types/any.rs
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/types/typeobject.rs
Expand Up @@ -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
}

Expand Down

0 comments on commit 3341d10

Please sign in to comment.