Merge pull request #1367 from PyO3/modern-path
Replace edition2015-style paths
This commit is contained in:
commit
4d242133a6
|
@ -51,7 +51,7 @@ impl<'a> Enum<'a> {
|
||||||
for (i, var) in self.variants.iter().enumerate() {
|
for (i, var) in self.variants.iter().enumerate() {
|
||||||
let struct_derive = var.build();
|
let struct_derive = var.build();
|
||||||
let ext = quote!(
|
let ext = quote!(
|
||||||
let maybe_ret = || -> ::pyo3::PyResult<Self> {
|
let maybe_ret = || -> pyo3::PyResult<Self> {
|
||||||
#struct_derive
|
#struct_derive
|
||||||
}();
|
}();
|
||||||
if maybe_ret.is_ok() {
|
if maybe_ret.is_ok() {
|
||||||
|
@ -74,7 +74,7 @@ impl<'a> Enum<'a> {
|
||||||
#(#var_extracts)*
|
#(#var_extracts)*
|
||||||
let type_name = obj.get_type().name()?;
|
let type_name = obj.get_type().name()?;
|
||||||
let err_msg = format!("'{}' object cannot be converted to '{}'", type_name, #error_names);
|
let err_msg = format!("'{}' object cannot be converted to '{}'", type_name, #error_names);
|
||||||
Err(::pyo3::exceptions::PyTypeError::new_err(err_msg))
|
Err(pyo3::exceptions::PyTypeError::new_err(err_msg))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,9 +255,9 @@ impl<'a> Container<'a> {
|
||||||
quote!("")
|
quote!("")
|
||||||
};
|
};
|
||||||
quote!(
|
quote!(
|
||||||
let s = <::pyo3::types::PyTuple as ::pyo3::conversion::PyTryFrom>::try_from(obj)?;
|
let s = <pyo3::types::PyTuple as pyo3::conversion::PyTryFrom>::try_from(obj)?;
|
||||||
if s.len() != #len {
|
if s.len() != #len {
|
||||||
return Err(::pyo3::exceptions::PyValueError::new_err(#msg))
|
return Err(pyo3::exceptions::PyValueError::new_err(#msg))
|
||||||
}
|
}
|
||||||
Ok(#self_ty(#fields))
|
Ok(#self_ty(#fields))
|
||||||
)
|
)
|
||||||
|
@ -512,8 +512,8 @@ pub fn build_derive_from_pyobject(tokens: &DeriveInput) -> Result<TokenStream> {
|
||||||
let ident = &tokens.ident;
|
let ident = &tokens.ident;
|
||||||
Ok(quote!(
|
Ok(quote!(
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl#trait_generics ::pyo3::FromPyObject<#lt_param> for #ident#generics #where_clause {
|
impl#trait_generics pyo3::FromPyObject<#lt_param> for #ident#generics #where_clause {
|
||||||
fn extract(obj: &#lt_param ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
|
fn extract(obj: &#lt_param pyo3::PyAny) -> pyo3::PyResult<Self> {
|
||||||
#derives
|
#derives
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -302,7 +302,7 @@ pub(crate) fn impl_wrap_getter(
|
||||||
let slf = self_ty.receiver(cls);
|
let slf = self_ty.receiver(cls);
|
||||||
Ok(quote! {
|
Ok(quote! {
|
||||||
unsafe extern "C" fn __wrap(
|
unsafe extern "C" fn __wrap(
|
||||||
_slf: *mut pyo3::ffi::PyObject, _: *mut ::std::os::raw::c_void) -> *mut pyo3::ffi::PyObject
|
_slf: *mut pyo3::ffi::PyObject, _: *mut std::os::raw::c_void) -> *mut pyo3::ffi::PyObject
|
||||||
{
|
{
|
||||||
const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#python_name),"()");
|
const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#python_name),"()");
|
||||||
pyo3::callback_body_without_convert!(_py, {
|
pyo3::callback_body_without_convert!(_py, {
|
||||||
|
@ -357,7 +357,7 @@ pub(crate) fn impl_wrap_setter(
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
unsafe extern "C" fn __wrap(
|
unsafe extern "C" fn __wrap(
|
||||||
_slf: *mut pyo3::ffi::PyObject,
|
_slf: *mut pyo3::ffi::PyObject,
|
||||||
_value: *mut pyo3::ffi::PyObject, _: *mut ::std::os::raw::c_void) -> pyo3::libc::c_int
|
_value: *mut pyo3::ffi::PyObject, _: *mut std::os::raw::c_void) -> pyo3::libc::c_int
|
||||||
{
|
{
|
||||||
const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#python_name),"()");
|
const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#python_name),"()");
|
||||||
pyo3::callback_body_without_convert!(_py, {
|
pyo3::callback_body_without_convert!(_py, {
|
||||||
|
|
|
@ -20,7 +20,7 @@ extern "C" {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn PyEval_CallObject(func: *mut PyObject, arg: *mut PyObject) -> *mut PyObject {
|
pub unsafe fn PyEval_CallObject(func: *mut PyObject, arg: *mut PyObject) -> *mut PyObject {
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
PyEval_CallObjectWithKeywords(func, arg, ::std::ptr::null_mut())
|
PyEval_CallObjectWithKeywords(func, arg, std::ptr::null_mut())
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -52,10 +52,10 @@ pub struct PyMethodDef {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const PyMethodDef_INIT: PyMethodDef = PyMethodDef {
|
pub const PyMethodDef_INIT: PyMethodDef = PyMethodDef {
|
||||||
ml_name: ::std::ptr::null(),
|
ml_name: std::ptr::null(),
|
||||||
ml_meth: None,
|
ml_meth: None,
|
||||||
ml_flags: 0,
|
ml_flags: 0,
|
||||||
ml_doc: ::std::ptr::null(),
|
ml_doc: std::ptr::null(),
|
||||||
};
|
};
|
||||||
|
|
||||||
impl Default for PyMethodDef {
|
impl Default for PyMethodDef {
|
||||||
|
|
|
@ -58,7 +58,7 @@ pub const PyModuleDef_HEAD_INIT: PyModuleDef_Base = PyModuleDef_Base {
|
||||||
ob_base: PyObject_HEAD_INIT,
|
ob_base: PyObject_HEAD_INIT,
|
||||||
m_init: None,
|
m_init: None,
|
||||||
m_index: 0,
|
m_index: 0,
|
||||||
m_copy: ::std::ptr::null_mut(),
|
m_copy: std::ptr::null_mut(),
|
||||||
};
|
};
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
@ -87,11 +87,11 @@ pub struct PyModuleDef {
|
||||||
|
|
||||||
pub const PyModuleDef_INIT: PyModuleDef = PyModuleDef {
|
pub const PyModuleDef_INIT: PyModuleDef = PyModuleDef {
|
||||||
m_base: PyModuleDef_HEAD_INIT,
|
m_base: PyModuleDef_HEAD_INIT,
|
||||||
m_name: ::std::ptr::null(),
|
m_name: std::ptr::null(),
|
||||||
m_doc: ::std::ptr::null(),
|
m_doc: std::ptr::null(),
|
||||||
m_size: 0,
|
m_size: 0,
|
||||||
m_methods: ::std::ptr::null_mut(),
|
m_methods: std::ptr::null_mut(),
|
||||||
m_slots: ::std::ptr::null_mut(),
|
m_slots: std::ptr::null_mut(),
|
||||||
m_traverse: None,
|
m_traverse: None,
|
||||||
m_clear: None,
|
m_clear: None,
|
||||||
m_free: None,
|
m_free: None,
|
||||||
|
|
|
@ -29,27 +29,27 @@ pub struct PyObject {
|
||||||
#[cfg(py_sys_config = "Py_TRACE_REFS")]
|
#[cfg(py_sys_config = "Py_TRACE_REFS")]
|
||||||
#[cfg(not(PyPy))]
|
#[cfg(not(PyPy))]
|
||||||
pub const PyObject_HEAD_INIT: PyObject = PyObject {
|
pub const PyObject_HEAD_INIT: PyObject = PyObject {
|
||||||
_ob_next: ::std::ptr::null_mut(),
|
_ob_next: std::ptr::null_mut(),
|
||||||
_ob_prev: ::std::ptr::null_mut(),
|
_ob_prev: std::ptr::null_mut(),
|
||||||
ob_refcnt: 1,
|
ob_refcnt: 1,
|
||||||
ob_type: ::std::ptr::null_mut(),
|
ob_type: std::ptr::null_mut(),
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(not(py_sys_config = "Py_TRACE_REFS"))]
|
#[cfg(not(py_sys_config = "Py_TRACE_REFS"))]
|
||||||
#[cfg(not(PyPy))]
|
#[cfg(not(PyPy))]
|
||||||
pub const PyObject_HEAD_INIT: PyObject = PyObject {
|
pub const PyObject_HEAD_INIT: PyObject = PyObject {
|
||||||
ob_refcnt: 1,
|
ob_refcnt: 1,
|
||||||
ob_type: ::std::ptr::null_mut(),
|
ob_type: std::ptr::null_mut(),
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(py_sys_config = "Py_TRACE_REFS")]
|
#[cfg(py_sys_config = "Py_TRACE_REFS")]
|
||||||
#[cfg(PyPy)]
|
#[cfg(PyPy)]
|
||||||
pub const PyObject_HEAD_INIT: PyObject = PyObject {
|
pub const PyObject_HEAD_INIT: PyObject = PyObject {
|
||||||
_ob_next: ::std::ptr::null_mut(),
|
_ob_next: std::ptr::null_mut(),
|
||||||
_ob_prev: ::std::ptr::null_mut(),
|
_ob_prev: std::ptr::null_mut(),
|
||||||
ob_refcnt: 1,
|
ob_refcnt: 1,
|
||||||
ob_pypy_link: 0,
|
ob_pypy_link: 0,
|
||||||
ob_type: ::std::ptr::null_mut(),
|
ob_type: std::ptr::null_mut(),
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(not(py_sys_config = "Py_TRACE_REFS"))]
|
#[cfg(not(py_sys_config = "Py_TRACE_REFS"))]
|
||||||
|
@ -57,7 +57,7 @@ pub const PyObject_HEAD_INIT: PyObject = PyObject {
|
||||||
pub const PyObject_HEAD_INIT: PyObject = PyObject {
|
pub const PyObject_HEAD_INIT: PyObject = PyObject {
|
||||||
ob_refcnt: 1,
|
ob_refcnt: 1,
|
||||||
ob_pypy_link: 0,
|
ob_pypy_link: 0,
|
||||||
ob_type: ::std::ptr::null_mut(),
|
ob_type: std::ptr::null_mut(),
|
||||||
};
|
};
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
@ -413,7 +413,7 @@ mod typeobject {
|
||||||
#[cfg(Py_3_8)]
|
#[cfg(Py_3_8)]
|
||||||
pub tp_vectorcall: Option<object::vectorcallfunc>,
|
pub tp_vectorcall: Option<object::vectorcallfunc>,
|
||||||
#[cfg(PyPy)]
|
#[cfg(PyPy)]
|
||||||
pub tp_pypy_flags: ::std::os::raw::c_long,
|
pub tp_pypy_flags: std::os::raw::c_long,
|
||||||
#[cfg(py_sys_config = "COUNT_ALLOCS")]
|
#[cfg(py_sys_config = "COUNT_ALLOCS")]
|
||||||
pub tp_allocs: Py_ssize_t,
|
pub tp_allocs: Py_ssize_t,
|
||||||
#[cfg(py_sys_config = "COUNT_ALLOCS")]
|
#[cfg(py_sys_config = "COUNT_ALLOCS")]
|
||||||
|
|
|
@ -43,7 +43,7 @@ pub struct PyObjectArenaAllocator {
|
||||||
impl Default for PyObjectArenaAllocator {
|
impl Default for PyObjectArenaAllocator {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
unsafe { ::std::mem::zeroed() }
|
unsafe { std::mem::zeroed() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(not(Py_LIMITED_API))]
|
#[cfg(not(Py_LIMITED_API))]
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub struct PyHash_FuncDef {
|
||||||
impl Default for PyHash_FuncDef {
|
impl Default for PyHash_FuncDef {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
unsafe { ::std::mem::zeroed() }
|
unsafe { std::mem::zeroed() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,5 +5,5 @@ pub type Py_ssize_t = ::libc::ssize_t;
|
||||||
pub type Py_hash_t = Py_ssize_t;
|
pub type Py_hash_t = Py_ssize_t;
|
||||||
pub type Py_uhash_t = ::libc::size_t;
|
pub type Py_uhash_t = ::libc::size_t;
|
||||||
|
|
||||||
pub const PY_SSIZE_T_MIN: Py_ssize_t = ::std::isize::MIN as Py_ssize_t;
|
pub const PY_SSIZE_T_MIN: Py_ssize_t = std::isize::MIN as Py_ssize_t;
|
||||||
pub const PY_SSIZE_T_MAX: Py_ssize_t = ::std::isize::MAX as Py_ssize_t;
|
pub const PY_SSIZE_T_MAX: Py_ssize_t = std::isize::MAX as Py_ssize_t;
|
||||||
|
|
|
@ -33,20 +33,20 @@ macro_rules! pyobject_native_type_base(
|
||||||
($name: ty $(;$generics: ident)* ) => {
|
($name: ty $(;$generics: ident)* ) => {
|
||||||
unsafe impl<$($generics,)*> $crate::PyNativeType for $name {}
|
unsafe impl<$($generics,)*> $crate::PyNativeType for $name {}
|
||||||
|
|
||||||
impl<$($generics,)*> ::std::fmt::Debug for $name {
|
impl<$($generics,)*> std::fmt::Debug for $name {
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter)
|
fn fmt(&self, f: &mut std::fmt::Formatter)
|
||||||
-> Result<(), ::std::fmt::Error>
|
-> Result<(), std::fmt::Error>
|
||||||
{
|
{
|
||||||
let s = self.repr().map_err(|_| ::std::fmt::Error)?;
|
let s = self.repr().map_err(|_| std::fmt::Error)?;
|
||||||
f.write_str(&s.to_string_lossy())
|
f.write_str(&s.to_string_lossy())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<$($generics,)*> ::std::fmt::Display for $name {
|
impl<$($generics,)*> std::fmt::Display for $name {
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter)
|
fn fmt(&self, f: &mut std::fmt::Formatter)
|
||||||
-> Result<(), ::std::fmt::Error>
|
-> Result<(), std::fmt::Error>
|
||||||
{
|
{
|
||||||
let s = self.str().map_err(|_| ::std::fmt::Error)?;
|
let s = self.str().map_err(|_| std::fmt::Error)?;
|
||||||
f.write_str(&s.to_string_lossy())
|
f.write_str(&s.to_string_lossy())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,14 +78,14 @@ macro_rules! pyobject_native_type_named (
|
||||||
($name: ty $(;$generics: ident)*) => {
|
($name: ty $(;$generics: ident)*) => {
|
||||||
$crate::pyobject_native_type_base!($name $(;$generics)*);
|
$crate::pyobject_native_type_base!($name $(;$generics)*);
|
||||||
|
|
||||||
impl<$($generics,)*> ::std::convert::AsRef<$crate::PyAny> for $name {
|
impl<$($generics,)*> std::convert::AsRef<$crate::PyAny> for $name {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_ref(&self) -> &$crate::PyAny {
|
fn as_ref(&self) -> &$crate::PyAny {
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<$($generics,)*> ::std::ops::Deref for $name {
|
impl<$($generics,)*> std::ops::Deref for $name {
|
||||||
type Target = $crate::PyAny;
|
type Target = $crate::PyAny;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -119,7 +119,7 @@ macro_rules! pyobject_native_type_named (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, $($generics,)*> ::std::convert::From<&'a $name> for &'a $crate::PyAny {
|
impl<'a, $($generics,)*> std::convert::From<&'a $name> for &'a $crate::PyAny {
|
||||||
fn from(ob: &'a $name) -> Self {
|
fn from(ob: &'a $name) -> Self {
|
||||||
unsafe{&*(ob as *const $name as *const $crate::PyAny)}
|
unsafe{&*(ob as *const $name as *const $crate::PyAny)}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue