Skip to content

Commit

Permalink
Get ready for rust 2018
Browse files Browse the repository at this point in the history
  • Loading branch information
konstin committed Oct 31, 2018
1 parent dbaa2de commit 8b27f1e
Show file tree
Hide file tree
Showing 95 changed files with 546 additions and 546 deletions.
16 changes: 8 additions & 8 deletions src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ use std::ffi::CStr;
use std::os::raw;
use std::{cell, mem, slice};

use err::{self, PyResult};
use exceptions;
use ffi;
use python::{Python, ToPyPointer};
use types::PyObjectRef;
use crate::err::{self, PyResult};
use crate::exceptions;
use crate::ffi;
use crate::python::{Python, ToPyPointer};
use crate::types::PyObjectRef;

/// Allows access to the underlying buffer used by a python object such as `bytes`, `bytearray` or `array.array`.
#[repr(transparent)]
Expand Down Expand Up @@ -661,17 +661,17 @@ impl_element!(f64, Float);
#[cfg(test)]
mod test {
use super::PyBuffer;
use python::Python;
use crate::python::Python;
use std;

#[allow(unused_imports)]
use objectprotocol::ObjectProtocol;
use crate::objectprotocol::ObjectProtocol;

#[test]
fn test_compatible_size() {
// for the cast in PyBuffer::shape()
assert_eq!(
std::mem::size_of::<::ffi::Py_ssize_t>(),
std::mem::size_of::<crate::ffi::Py_ssize_t>(),
std::mem::size_of::<usize>()
);
}
Expand Down
10 changes: 5 additions & 5 deletions src/callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
use std::os::raw::c_int;
use std::{isize, ptr};

use conversion::IntoPyObject;
use err::PyResult;
use ffi::{self, Py_hash_t};
use python::{IntoPyPointer, Python};
use types::exceptions::OverflowError;
use crate::conversion::IntoPyObject;
use crate::err::PyResult;
use crate::ffi::{self, Py_hash_t};
use crate::python::{IntoPyPointer, Python};
use crate::types::exceptions::OverflowError;

pub trait CallbackConverter<S> {
type R;
Expand Down
22 changes: 11 additions & 11 deletions src/class/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
use std::os::raw::c_int;
use std::ptr;

use callback::{BoolCallbackConverter, HashConverter, PyObjectCallbackConverter};
use class::methods::PyMethodDef;
use conversion::{FromPyObject, IntoPyObject};
use err::{PyErr, PyResult};
use ffi;
use objectprotocol::ObjectProtocol;
use python::{IntoPyPointer, Python};
use typeob::PyTypeInfo;
use types::{exceptions, PyObjectRef};
use CompareOp;
use crate::callback::{BoolCallbackConverter, HashConverter, PyObjectCallbackConverter};
use crate::class::methods::PyMethodDef;
use crate::conversion::{FromPyObject, IntoPyObject};
use crate::err::{PyErr, PyResult};
use crate::ffi;
use crate::objectprotocol::ObjectProtocol;
use crate::python::{IntoPyPointer, Python};
use crate::typeob::PyTypeInfo;
use crate::types::{exceptions, PyObjectRef};
use crate::CompareOp;

/// Basic python class customization
#[allow(unused_variables)]
Expand Down Expand Up @@ -426,7 +426,7 @@ where
where
T: for<'p> PyObjectRichcmpProtocol<'p>,
{
let _pool = ::GILPool::new();
let _pool = crate::GILPool::new();
let py = Python::assume_gil_acquired();
let slf = py.from_borrowed_ptr::<T>(slf);
let arg = py.from_borrowed_ptr::<PyObjectRef>(arg);
Expand Down
14 changes: 7 additions & 7 deletions src/class/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
//! c-api
use std::os::raw::c_int;

use callback::UnitCallbackConverter;
use err::PyResult;
use ffi;
use typeob::PyTypeInfo;
use crate::callback::UnitCallbackConverter;
use crate::err::PyResult;
use crate::ffi;
use crate::typeob::PyTypeInfo;

/// Buffer protocol interface
///
Expand Down Expand Up @@ -85,12 +85,12 @@ where
where
T: for<'p> PyBufferGetBufferProtocol<'p>,
{
let _pool = ::GILPool::new();
let py = ::Python::assume_gil_acquired();
let _pool = crate::GILPool::new();
let py = crate::Python::assume_gil_acquired();
let slf = py.mut_from_borrowed_ptr::<T>(slf);

let result = slf.bf_getbuffer(arg1, arg2).into();
::callback::cb_convert(UnitCallbackConverter, py, result)
crate::callback::cb_convert(UnitCallbackConverter, py, result)
}
Some(wrap::<T>)
}
Expand Down
16 changes: 8 additions & 8 deletions src/class/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
//! Trait and support implementation for context manager api
//!
use class::methods::PyMethodDef;
use err::PyResult;
use typeob::PyTypeInfo;
use crate::class::methods::PyMethodDef;
use crate::err::PyResult;
use crate::typeob::PyTypeInfo;

/// Context manager interface
#[allow(unused_variables)]
Expand All @@ -32,15 +32,15 @@ pub trait PyContextProtocol<'p>: PyTypeInfo {
}

pub trait PyContextEnterProtocol<'p>: PyContextProtocol<'p> {
type Success: ::IntoPyObject;
type Success: crate::IntoPyObject;
type Result: Into<PyResult<Self::Success>>;
}

pub trait PyContextExitProtocol<'p>: PyContextProtocol<'p> {
type ExcType: ::FromPyObject<'p>;
type ExcValue: ::FromPyObject<'p>;
type Traceback: ::FromPyObject<'p>;
type Success: ::IntoPyObject;
type ExcType: crate::FromPyObject<'p>;
type ExcValue: crate::FromPyObject<'p>;
type Traceback: crate::FromPyObject<'p>;
type Success: crate::IntoPyObject;
type Result: Into<PyResult<Self::Success>>;
}

Expand Down
14 changes: 7 additions & 7 deletions src/class/descr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
use std::os::raw::c_int;

use callback::{PyObjectCallbackConverter, UnitCallbackConverter};
use class::methods::PyMethodDef;
use conversion::{FromPyObject, IntoPyObject};
use err::PyResult;
use ffi;
use typeob::PyTypeInfo;
use types::{PyObjectRef, PyType};
use crate::callback::{PyObjectCallbackConverter, UnitCallbackConverter};
use crate::class::methods::PyMethodDef;
use crate::conversion::{FromPyObject, IntoPyObject};
use crate::err::PyResult;
use crate::ffi;
use crate::typeob::PyTypeInfo;
use crate::types::{PyObjectRef, PyType};

/// Descriptor interface
#[allow(unused_variables)]
Expand Down
10 changes: 5 additions & 5 deletions src/class/gc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use std::os::raw::{c_int, c_void};

use ffi;
use python::{Python, ToPyPointer};
use typeob::PyTypeInfo;
use crate::ffi;
use crate::python::{Python, ToPyPointer};
use crate::typeob::PyTypeInfo;

#[repr(transparent)]
pub struct PyTraverseError(c_int);
Expand Down Expand Up @@ -91,7 +91,7 @@ where
where
T: for<'p> PyGCTraverseProtocol<'p>,
{
let _pool = ::GILPool::new();
let _pool = crate::GILPool::new();
let py = Python::assume_gil_acquired();
let slf = py.mut_from_borrowed_ptr::<T>(slf);

Expand Down Expand Up @@ -128,7 +128,7 @@ where
where
T: for<'p> PyGCClearProtocol<'p>,
{
let _pool = ::GILPool::new();
let _pool = crate::GILPool::new();
let py = Python::assume_gil_acquired();
let slf = py.mut_from_borrowed_ptr::<T>(slf);

Expand Down
16 changes: 8 additions & 8 deletions src/class/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
use std::ptr;

use callback::{CallbackConverter, PyObjectCallbackConverter};
use conversion::IntoPyObject;
use err::PyResult;
use ffi;
use python::{IntoPyPointer, Python};
use typeob::PyTypeInfo;
use crate::callback::{CallbackConverter, PyObjectCallbackConverter};
use crate::conversion::IntoPyObject;
use crate::err::PyResult;
use crate::ffi;
use crate::python::{IntoPyPointer, Python};
use crate::typeob::PyTypeInfo;

/// Python Iterator Interface.
///
Expand All @@ -33,12 +33,12 @@ pub trait PyIterProtocol<'p>: PyTypeInfo {
}

pub trait PyIterIterProtocol<'p>: PyIterProtocol<'p> {
type Success: ::IntoPyObject;
type Success: crate::IntoPyObject;
type Result: Into<PyResult<Self::Success>>;
}

pub trait PyIterNextProtocol<'p>: PyIterProtocol<'p> {
type Success: ::IntoPyObject;
type Success: crate::IntoPyObject;
type Result: Into<PyResult<Option<Self::Success>>>;
}

Expand Down
16 changes: 8 additions & 8 deletions src/class/mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
//! Python Mapping Interface
//! Trait and support implementation for implementing mapping support
use callback::{LenResultConverter, PyObjectCallbackConverter};
use class::methods::PyMethodDef;
use conversion::{FromPyObject, IntoPyObject};
use err::{PyErr, PyResult};
use ffi;
use python::Python;
use typeob::PyTypeInfo;
use types::exceptions;
use crate::callback::{LenResultConverter, PyObjectCallbackConverter};
use crate::class::methods::PyMethodDef;
use crate::conversion::{FromPyObject, IntoPyObject};
use crate::err::{PyErr, PyResult};
use crate::ffi;
use crate::python::Python;
use crate::typeob::PyTypeInfo;
use crate::types::exceptions;

/// Mapping interface
#[allow(unused_variables)]
Expand Down
2 changes: 1 addition & 1 deletion src/class/methods.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2017-present PyO3 Project and Contributors

use ffi;
use crate::ffi;
use libc::c_int;
use std;
use std::ffi::CString;
Expand Down
6 changes: 3 additions & 3 deletions src/class/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#[macro_use]
mod macros;

pub mod async;
pub mod pyasync;
pub mod basic;
pub mod buffer;
pub mod context;
Expand All @@ -17,7 +17,7 @@ pub mod methods;
pub mod number;
pub mod sequence;

pub use self::async::PyAsyncProtocol;
pub use self::pyasync::PyAsyncProtocol;
pub use self::basic::PyObjectProtocol;
pub use self::buffer::PyBufferProtocol;
pub use self::context::PyContextProtocol;
Expand All @@ -30,7 +30,7 @@ pub use self::sequence::PySequenceProtocol;
pub use self::gc::{PyGCProtocol, PyTraverseError, PyVisit};
pub use self::methods::{PyGetterDef, PyMethodDef, PyMethodDefType, PyMethodType, PySetterDef};

use ffi;
use crate::ffi;

/// Operators for the __richcmp__ method
#[derive(Debug)]
Expand Down
14 changes: 7 additions & 7 deletions src/class/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
//! Python Number Interface
//! Trait and support implementation for implementing number protocol
use callback::PyObjectCallbackConverter;
use class::basic::PyObjectProtocolImpl;
use class::methods::PyMethodDef;
use err::PyResult;
use ffi;
use typeob::PyTypeInfo;
use {FromPyObject, IntoPyObject};
use crate::callback::PyObjectCallbackConverter;
use crate::class::basic::PyObjectProtocolImpl;
use crate::class::methods::PyMethodDef;
use crate::err::PyResult;
use crate::ffi;
use crate::typeob::PyTypeInfo;
use crate::{FromPyObject, IntoPyObject};

/// Number interface
#[allow(unused_variables)]
Expand Down
34 changes: 17 additions & 17 deletions src/class/async.rs → src/class/pyasync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
//! [PEP-0492](https://www.python.org/dev/peps/pep-0492/)
//!
use callback::PyObjectCallbackConverter;
use class::methods::PyMethodDef;
use err::PyResult;
use ffi;
use typeob::PyTypeInfo;
use crate::callback::PyObjectCallbackConverter;
use crate::class::methods::PyMethodDef;
use crate::err::PyResult;
use crate::ffi;
use crate::typeob::PyTypeInfo;

/// Python Async/Await support interface.
///
Expand Down Expand Up @@ -61,30 +61,30 @@ pub trait PyAsyncProtocol<'p>: PyTypeInfo {
}

pub trait PyAsyncAwaitProtocol<'p>: PyAsyncProtocol<'p> {
type Success: ::IntoPyObject;
type Success: crate::IntoPyObject;
type Result: Into<PyResult<Self::Success>>;
}

pub trait PyAsyncAiterProtocol<'p>: PyAsyncProtocol<'p> {
type Success: ::IntoPyObject;
type Success: crate::IntoPyObject;
type Result: Into<PyResult<Self::Success>>;
}

pub trait PyAsyncAnextProtocol<'p>: PyAsyncProtocol<'p> {
type Success: ::IntoPyObject;
type Success: crate::IntoPyObject;
type Result: Into<PyResult<Option<Self::Success>>>;
}

pub trait PyAsyncAenterProtocol<'p>: PyAsyncProtocol<'p> {
type Success: ::IntoPyObject;
type Success: crate::IntoPyObject;
type Result: Into<PyResult<Self::Success>>;
}

pub trait PyAsyncAexitProtocol<'p>: PyAsyncProtocol<'p> {
type ExcType: ::FromPyObject<'p>;
type ExcValue: ::FromPyObject<'p>;
type Traceback: ::FromPyObject<'p>;
type Success: ::IntoPyObject;
type ExcType: crate::FromPyObject<'p>;
type ExcValue: crate::FromPyObject<'p>;
type Traceback: crate::FromPyObject<'p>;
type Success: crate::IntoPyObject;
type Result: Into<PyResult<Self::Success>>;
}

Expand Down Expand Up @@ -189,10 +189,10 @@ impl<'p, T> PyAsyncAnextProtocolImpl for T where T: PyAsyncProtocol<'p> {}
#[cfg(Py_3)]
mod anext {
use super::{PyAsyncAnextProtocol, PyAsyncAnextProtocolImpl};
use callback::CallbackConverter;
use conversion::IntoPyObject;
use ffi;
use python::{IntoPyPointer, Python};
use crate::callback::CallbackConverter;
use crate::conversion::IntoPyObject;
use crate::ffi;
use crate::python::{IntoPyPointer, Python};
use std::ptr;

pub struct IterANextResultConverter;
Expand Down
Loading

0 comments on commit 8b27f1e

Please sign in to comment.