From 84f6834b170e9eb2bd4e9e1ee62552c73b971c29 Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Thu, 19 Nov 2020 14:38:14 +0000 Subject: [PATCH] ci fixes --- benches/bench_call.rs | 25 ++++++++++++------------- src/ffi/cpython/abstract_.rs | 18 +++++++++--------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/benches/bench_call.rs b/benches/bench_call.rs index 01d9b6af1b7..45b4ffd3d11 100644 --- a/benches/bench_call.rs +++ b/benches/bench_call.rs @@ -4,25 +4,22 @@ extern crate test; use pyo3::prelude::*; use test::Bencher; - macro_rules! test_module { ($py:ident, $code:literal) => { - PyModule::from_code( - $py, - indoc::indoc!($code), - file!(), - "test_module" - ).expect("module creation failed") + PyModule::from_code($py, indoc::indoc!($code), file!(), "test_module") + .expect("module creation failed") }; } #[bench] fn bench_call_0(b: &mut Bencher) { Python::with_gil(|py| { - - let module = test_module!(py, r#" + let module = test_module!( + py, + r#" def foo(): pass - "#); + "# + ); let foo = module.getattr("foo").unwrap(); @@ -37,11 +34,13 @@ fn bench_call_0(b: &mut Bencher) { #[bench] fn bench_call_method_0(b: &mut Bencher) { Python::with_gil(|py| { - - let module = test_module!(py, r#" + let module = test_module!( + py, + r#" class Foo: def foo(self): pass - "#); + "# + ); let foo = module.getattr("Foo").unwrap().call0().unwrap(); diff --git a/src/ffi/cpython/abstract_.rs b/src/ffi/cpython/abstract_.rs index 7b03bfb15ff..8debc76d27c 100644 --- a/src/ffi/cpython/abstract_.rs +++ b/src/ffi/cpython/abstract_.rs @@ -1,10 +1,10 @@ -use crate::ffi::{Py_ssize_t, PyObject, Py_buffer}; -use std::os::raw::{c_int, c_void, c_char}; +use crate::ffi::{PyObject, Py_TYPE, Py_buffer, Py_ssize_t}; +use std::os::raw::{c_char, c_int, c_void}; #[cfg(all(Py_3_8, not(PyPy)))] use crate::ffi::{ vectorcallfunc, PyCallable_Check, PyThreadState, PyThreadState_GET, PyTuple_Check, - PyType_HasFeature, Py_TPFLAGS_HAVE_VECTORCALL, Py_TYPE, + PyType_HasFeature, Py_TPFLAGS_HAVE_VECTORCALL, }; extern "C" { @@ -214,7 +214,6 @@ extern "C" { pub fn PyObject_CheckBuffer(obj: *mut PyObject) -> c_int; } - #[cfg(not(any(Py_3_9, PyPy)))] #[inline] pub unsafe fn PyObject_CheckBuffer(o: *mut PyObject) -> c_int { @@ -269,14 +268,11 @@ extern "C" { #[inline] pub unsafe fn PyIter_Check(o: *mut PyObject) -> c_int { (match (*Py_TYPE(o)).tp_iternext { - Some(tp_iternext) => { - tp_iternext != crate::ffi::object::_PyObject_NextNotImplemented as _ - } + Some(tp_iternext) => tp_iternext != crate::ffi::object::_PyObject_NextNotImplemented as _, None => false, }) as c_int } - // skipped PySequence_ITEM pub const PY_ITERSEARCH_COUNT: c_int = 1; @@ -285,7 +281,11 @@ pub const PY_ITERSEARCH_CONTAINS: c_int = 3; extern "C" { #[cfg(not(PyPy))] - pub fn _PySequence_IterSearch(seq: *mut PyObject, obj: *mut PyObject, operation: c_int) -> Py_ssize_t; + pub fn _PySequence_IterSearch( + seq: *mut PyObject, + obj: *mut PyObject, + operation: c_int, + ) -> Py_ssize_t; } // skipped _PyObject_RealIsInstance