Remove ::pyo3::argparse::get_kwargs for from_borrowed_ptr_or_opt

This commit is contained in:
konstin 2018-09-03 20:50:02 +02:00
parent 29c882577c
commit e6569ae61e
4 changed files with 9 additions and 21 deletions

View File

@ -17,6 +17,6 @@ default: test
test:
cargo test $(CARGO_FLAGS)
pip install setuptools-rust pytest pytest-benchmark
pip install setuptools-rust pytest pytest-benchmark tox
cd examples/word-count && python setup.py install && pytest -v tests
cd examples/word-count-cls && python setup.py install && pytest -v tests
cd examples/rustapi_module && tox

View File

@ -91,7 +91,7 @@ pub fn py2_init(fnname: &syn::Ident, name: &syn::Ident, doc: syn::Lit) -> TokenS
}
}
/// Finds and takes care of the #[pyfn(...)] in #[pymodinit]
/// Finds and takes care of the #[pyfn(...)] in `#[pymodinit]`
pub fn process_functions_in_module(func: &mut syn::ItemFn) {
let mut stmts: Vec<syn::Stmt> = Vec::new();

View File

@ -89,7 +89,7 @@ pub fn impl_wrap(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec, noargs: bool
let _py = ::pyo3::Python::assume_gil_acquired();
let _slf = _py.mut_from_borrowed_ptr::<#cls>(_slf);
let _args = _py.from_borrowed_ptr::<::pyo3::PyTuple>(_args);
let _kwargs = ::pyo3::argparse::get_kwargs(_py, _kwargs);
let _kwargs: Option<&PyDict> = _py.from_borrowed_ptr_or_opt(_kwargs);
#body_to_result
::pyo3::callback::cb_convert(
@ -116,7 +116,7 @@ pub fn impl_proto_wrap(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec) -> Tok
let _py = ::pyo3::Python::assume_gil_acquired();
let _slf = _py.mut_from_borrowed_ptr::<#cls>(_slf);
let _args = _py.from_borrowed_ptr::<::pyo3::PyTuple>(_args);
let _kwargs = ::pyo3::argparse::get_kwargs(_py, _kwargs);
let _kwargs: Option<&PyDict> = _py.from_borrowed_ptr_or_opt(_kwargs);
let _result = {
#body
@ -162,7 +162,7 @@ pub fn impl_wrap_new(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec) -> Token
match ::pyo3::typeob::PyRawObject::new(_py, #cls::type_object(), _cls) {
Ok(_obj) => {
let _args = _py.from_borrowed_ptr::<::pyo3::PyTuple>(_args);
let _kwargs = ::pyo3::argparse::get_kwargs(_py, _kwargs);
let _kwargs: Option<&PyDict> = _py.from_borrowed_ptr_or_opt(_kwargs);
#body_to_result
@ -208,7 +208,7 @@ fn impl_wrap_init(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec) -> TokenStr
let _py = ::pyo3::Python::assume_gil_acquired();
let _slf = _py.mut_from_borrowed_ptr::<#cls>(_slf);
let _args = _py.from_borrowed_ptr::<::pyo3::PyTuple>(_args);
let _kwargs = ::pyo3::argparse::get_kwargs(_py, _kwargs);
let _kwargs: Option<&PyDict> = _py.from_borrowed_ptr_or_opt(_kwargs);
#body_to_result
match _result {
@ -254,7 +254,7 @@ pub fn impl_wrap_class(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec) -> Tok
let _py = ::pyo3::Python::assume_gil_acquired();
let _cls = ::pyo3::PyType::from_type_ptr(_py, _cls as *mut ::pyo3::ffi::PyTypeObject);
let _args = _py.from_borrowed_ptr::<::pyo3::PyTuple>(_args);
let _kwargs = ::pyo3::argparse::get_kwargs(_py, _kwargs);
let _kwargs: Option<&PyDict> = _py.from_borrowed_ptr_or_opt(_kwargs);
#body_to_result
::pyo3::callback::cb_convert(
@ -294,7 +294,7 @@ pub fn impl_wrap_static(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec) -> To
let _pool = ::pyo3::GILPool::new();
let _py = ::pyo3::Python::assume_gil_acquired();
let _args = _py.from_borrowed_ptr::<::pyo3::PyTuple>(_args);
let _kwargs = ::pyo3::argparse::get_kwargs(_py, _kwargs);
let _kwargs: Option<&PyDict> = _py.from_borrowed_ptr_or_opt(_kwargs);
#body_to_result
::pyo3::callback::cb_convert(

View File

@ -5,9 +5,7 @@
//! Python argument parsing
use conversion::PyTryFrom;
use err::PyResult;
use ffi;
use objects::{exc, PyDict, PyObjectRef, PyString, PyTuple};
use python::Python;
#[derive(Debug)]
/// Description of a python parameter; used for `parse_args()`.
@ -103,13 +101,3 @@ pub fn parse_args<'p>(
}
Ok(())
}
#[inline]
#[doc(hidden)]
pub unsafe fn get_kwargs(py: Python, ptr: *mut ffi::PyObject) -> Option<&PyDict> {
if ptr.is_null() {
None
} else {
Some(py.from_borrowed_ptr::<PyDict>(ptr))
}
}