python2 compatibility

This commit is contained in:
Nikolay Kim 2018-01-19 10:08:13 -08:00
parent b738c1a04b
commit 3681cf51e8
3 changed files with 4 additions and 1 deletions

View file

@ -2,6 +2,7 @@ Changes
-------
0.2.4 (2018-01-19)
^^^^^^^^^^^^^^^^^^
* Allow to get mutable ref from PyObject #106

View file

@ -48,10 +48,12 @@ impl<T> PyBufferProtocolImpl for T {
impl<'p, T> PyBufferProtocolImpl for T where T: PyBufferProtocol<'p>
{
#[inline]
#[cfg_attr(feature = "cargo-clippy", allow(needless_update))]
fn tp_as_buffer() -> Option<ffi::PyBufferProcs> {
Some(ffi::PyBufferProcs{
bf_getbuffer: Self::cb_bf_getbuffer(),
bf_releasebuffer: None,
.. ffi::PyBufferProcs_INIT
})
}
}

View file

@ -419,7 +419,7 @@ impl<'p> Python<'p> {
/// Release `ffi::PyObject` pointer.
/// Undefined behavior if the pointer is invalid.
#[inline]
#[cfg_attr(feature = "cargo-clippy", allow(not_unsafe_ptr_arg_deref))]
#[cfg_attr(feature = "cargo-clippy", allow(not_unsafe_ptr_arg_deref))]
pub fn xdecref(self, ptr: *mut ffi::PyObject) {
if !ptr.is_null() {
unsafe {ffi::Py_DECREF(ptr)};