Merge pull request #1047 from davidhewitt/cast-to-ptr-is-safe
Functions which cast reference to pointer are not unsafe.
This commit is contained in:
commit
8bbdbc4937
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue