Remove unused imports and variables.

This commit is contained in:
Daniel Grunwald 2015-06-27 23:49:53 +02:00
parent 3b02ef5b99
commit 9f2244bbcf
20 changed files with 35 additions and 56 deletions

View File

@ -19,8 +19,8 @@
use std;
use ffi;
use python::{Python, PythonObject, PythonObjectWithCheckedDowncast, ToPythonPointer};
use objects::{exc, PyObject, PyBool, PyTuple};
use err::{self, PyErr, PyResult};
use objects::PyObject;
use err::PyResult;
/// Conversion trait that allows various objects to be converted into Python objects.
pub trait ToPyObject<'p> {
@ -91,7 +91,7 @@ impl <'p, 's> ToPyObject<'p> for PyObject<'s> {
}
#[inline]
fn into_py_object(self, py: Python<'p>) -> PyObject<'p> {
fn into_py_object(self, _py: Python<'p>) -> PyObject<'p> {
// Transmute the lifetime.
// This is safe, because both lifetime variables represent the same lifetime:
// that of the python GIL acquisition.
@ -99,7 +99,7 @@ impl <'p, 's> ToPyObject<'p> for PyObject<'s> {
}
#[inline]
fn with_borrowed_ptr<F, R>(&self, py: Python<'p>, f: F) -> R
fn with_borrowed_ptr<F, R>(&self, _py: Python<'p>, f: F) -> R
where F: FnOnce(*mut ffi::PyObject) -> R {
f(self.as_ptr())
}

View File

@ -24,7 +24,7 @@ use objects::oldstyle::PyClass;
use ffi;
use libc;
use conversion::ToPyObject;
use std::ffi::{CString, CStr};
use std::ffi::CString;
/// Represents a Python exception that was raised.
#[derive(Clone, Debug)]
@ -244,7 +244,7 @@ pub unsafe fn result_from_owned_ptr(py : Python, p : *mut ffi::PyObject) -> PyRe
}
}
fn panic_after_error(py: Python) -> ! {
fn panic_after_error(_py: Python) -> ! {
unsafe { ffi::PyErr_Print(); }
panic!("Python API called failed");
}
@ -291,8 +291,8 @@ pub fn error_on_minusone(py : Python, result : libc::c_int) -> PyResult<()> {
#[cfg(test)]
mod tests {
use {Python, PyErr};
use objects::{PyObject, exc};
use objects::exc;
#[test]
fn set_typeerror() {
let gil = Python::acquire_gil();

View File

@ -16,7 +16,6 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
use libc::c_char;
use std::ptr;
use python::Python;
use objects::PyObject;

View File

@ -23,7 +23,7 @@
#![feature(utf8_error)] // for translating Utf8Error to Python exception
#![feature(plugin)]
#![plugin(interpolate_idents)]
#![allow(unused_imports, unused_variables)]
#![allow(unused_imports)] // because some imports are only necessary with python 2.x or 3.x
//! Rust bindings to the Python interpreter.
//!

View File

@ -16,13 +16,11 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
use std;
use std::{fmt, string};
use std::borrow::Cow;
use std::fmt;
use std::cmp::Ordering;
use ffi;
use libc;
use python::{Python, PythonObject, PythonObjectWithCheckedDowncast, ToPythonPointer};
use python::{PythonObject, ToPythonPointer};
use objects::{PyObject, PyTuple, PyDict, PyString};
use conversion::ToPyObject;
use err::{PyErr, PyResult, result_from_owned_ptr, error_on_minusone};

View File

@ -33,7 +33,7 @@ impl <'p> ToPyObject<'p> for bool {
}
#[inline]
fn with_borrowed_ptr<F, R>(&self, py: Python<'p>, f: F) -> R
fn with_borrowed_ptr<F, R>(&self, _py: Python<'p>, f: F) -> R
where F: FnOnce(*mut ffi::PyObject) -> R
{
// Avoid unnecessary Py_INCREF/Py_DECREF pair

View File

@ -16,7 +16,6 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
use std;
use ffi;
use python::{Python, ToPythonPointer, PythonObject};
use conversion::ToPyObject;

View File

@ -16,7 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
use python::{PythonObject, PythonObjectWithCheckedDowncast, ToPythonPointer};
use python::{PythonObject, ToPythonPointer};
use objects::PyObject;
use err::{PyErr, PyResult};
use ffi;

View File

@ -16,11 +16,9 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
use std;
use python::{Python, PythonObject, ToPythonPointer};
use err::{self, PyResult, PyErr};
use err::{self, PyResult};
use super::object::PyObject;
use super::exc;
use ffi::{self, Py_ssize_t};
use conversion::{ToPyObject, FromPyObject};
@ -140,7 +138,6 @@ impl <'p, T> ToPyObject<'p> for [T] where T: ToPyObject<'p> {
impl <'p, T> FromPyObject<'p> for Vec<T> where T: FromPyObject<'p> {
fn from_py_object(s: &PyObject<'p>) -> PyResult<'p, Vec<T>> {
let py = s.python();
let list = try!(s.cast_as::<PyList>());
let mut v = Vec::with_capacity(list.len());
for i in 0 .. list.len() {

View File

@ -22,7 +22,7 @@ use libc::c_char;
use python::{Python, PythonObject, ToPythonPointer};
use objectprotocol::ObjectProtocol;
use conversion::ToPyObject;
use objects::{PyObject, PyType, PyTuple, PyDict, exc};
use objects::{PyObject, PyTuple, PyDict, exc};
use err::{self, PyResult, PyErr};
use std::ffi::{CStr, CString};

View File

@ -19,12 +19,11 @@
extern crate num;
use libc::{c_long, c_double};
use std;
use python::{Python, PythonObject, ToPythonPointer};
use err::{self, PyResult, PyErr};
use super::object::PyObject;
use super::exc;
use ffi::{self, Py_ssize_t};
use ffi;
use conversion::{ToPyObject, FromPyObject};
/// Represents a Python `int` object.

View File

@ -17,11 +17,10 @@
// DEALINGS IN THE SOFTWARE.
use std::mem;
use libc;
use ffi;
use python::{Python, PythonObject, PythonObjectWithCheckedDowncast, PythonObjectWithTypeObject, PythonObjectDowncastError, ToPythonPointer};
use objects::PyType;
use err::{PyErr, PyResult};
use err::PyErr;
/// Represents a reference to a Python object.
///
@ -175,6 +174,7 @@ impl <'p> PyObject<'p> {
ptr
}
/*
/// Transmutes an owned FFI pointer to `&PyObject`.
/// Undefined behavior if the pointer is NULL or invalid.
#[inline]
@ -189,7 +189,8 @@ impl <'p> PyObject<'p> {
pub unsafe fn borrow_from_owned_ptr_slice<'a>(py : Python<'p>, ptr : &'a [*mut ffi::PyObject]) -> &'a [PyObject<'p>] {
mem::transmute(ptr)
}
*/
/// Gets the reference count of this Python object.
#[inline]
pub fn get_refcnt(&self) -> usize {

View File

@ -19,7 +19,7 @@
//! This module contains support for old-style classes. Only available in Python 2.x.
use ffi;
use python::{Python, PythonObject, ToPythonPointer};
use python::{PythonObject, ToPythonPointer};
use conversion::ToPyObject;
use err::{self, PyResult};
use super::object::PyObject;

View File

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE.
use std;
use std::{char, str};
use std::str;
use std::ascii::AsciiExt;
use std::borrow::Cow;
use libc::c_char;

View File

@ -16,7 +16,6 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
use std;
use python::{Python, PythonObject, ToPythonPointer};
use err::{self, PyResult, PyErr};
use super::object::PyObject;

View File

@ -16,13 +16,11 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
use python::{Python, PythonObject, PythonObjectWithCheckedDowncast, PythonObjectWithTypeObject, ToPythonPointer};
use python::{Python, PythonObject, ToPythonPointer};
use conversion::ToPyObject;
use objects::{PyObject, PyTuple, PyDict};
use err::{PyResult, result_from_owned_ptr};
use ffi;
use libc::c_char;
use std;
/// Represents a reference to a Python type object.
pub struct PyType<'p>(PyObject<'p>);

View File

@ -18,8 +18,7 @@
use std::sync::{Once, ONCE_INIT};
use ffi;
use python::{Python, ToPythonPointer};
use objects::PyObject;
use python::Python;
static START: Once = ONCE_INIT;
@ -162,7 +161,7 @@ impl <T> GILProtected<T> {
///
/// Requires a `Python` instance as proof that the GIL is acquired.
#[inline]
pub fn get<'a>(&'a self, py: Python<'a>) -> &'a T {
pub fn get<'a>(&'a self, _py: Python<'a>) -> &'a T {
&self.data
}

View File

@ -16,11 +16,9 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
use std::{ptr, marker};
use python::{Python, PythonObject};
use std::marker;
use python::PythonObject;
use objects::{PyObject, PyTuple, PyType};
use conversion::ToPyObject;
use super::{PythonBaseObject, PyRustObject, PyRustType};
use super::typebuilder::TypeMember;
use ffi;
use err;
@ -110,7 +108,7 @@ pub unsafe fn py_method_impl<'p, T, R>(
impl <'p, T> TypeMember<'p, T> for MethodDescriptor<T> where T: PythonObject<'p> {
#[inline]
fn into_descriptor(self, ty: &PyType<'p>, name: &str) -> PyObject<'p> {
fn into_descriptor(self, ty: &PyType<'p>, _name: &str) -> PyObject<'p> {
unsafe {
err::from_owned_ptr_or_panic(ty.python(),
ffi::PyDescr_NewMethod(ty.as_type_ptr(), self.0))
@ -200,7 +198,7 @@ pub unsafe fn py_class_method_impl<'p, R>(
impl <'p, T> TypeMember<'p, T> for ClassMethodDescriptor where T: PythonObject<'p> {
#[inline]
fn into_descriptor(self, ty: &PyType<'p>, name: &str) -> PyObject<'p> {
fn into_descriptor(self, ty: &PyType<'p>, _name: &str) -> PyObject<'p> {
unsafe {
err::from_owned_ptr_or_panic(ty.python(),
ffi::PyDescr_NewClassMethod(ty.as_type_ptr(), self.0))

View File

@ -20,7 +20,7 @@ use libc;
use ffi;
use python::{Python, ToPythonPointer, PythonObject};
use conversion::ToPyObject;
use objects::{PyObject, PyType, PyString, PyModule, PyDict};
use objects::{PyObject, PyType};
use std::{mem, ops, ptr, marker};
use err::{self, PyResult};
@ -56,7 +56,7 @@ impl <'p> PythonBaseObject<'p> for PyObject<'p> {
type InitType = ();
unsafe fn alloc(ty: &PyType<'p>, init_val: ()) -> PyResult<'p, PyObject<'p>> {
unsafe fn alloc(ty: &PyType<'p>, _init_val: ()) -> PyResult<'p, PyObject<'p>> {
let py = ty.python();
let ptr = ((*ty.as_type_ptr()).tp_alloc.unwrap())(ty.as_type_ptr(), 0);
err::result_from_owned_ptr(py, ptr)
@ -156,7 +156,7 @@ impl <'p, 's, T, B> ToPyObject<'p> for PyRustObject<'s, T, B> where T: 'static +
}
#[inline]
fn with_borrowed_ptr<F, R>(&self, py: Python<'p>, f: F) -> R
fn with_borrowed_ptr<F, R>(&self, _py: Python<'p>, f: F) -> R
where F: FnOnce(*mut ffi::PyObject) -> R {
f(self.as_ptr())
}
@ -203,7 +203,6 @@ pub struct PyRustType<'p, T, B = PyObject<'p>> where T: 'p + Send, B: PythonBase
impl <'p, T, B> PyRustType<'p, T, B> where T: 'p + Send, B: PythonBaseObject<'p> {
/// Creates a PyRustObject instance from a value.
pub fn create_instance(&self, val: T, base_val: B::InitType) -> PyRustObject<'p, T, B> {
let py = self.type_obj.python();
unsafe {
PythonBaseObject::alloc(&self.type_obj, (val, base_val)).unwrap()
}

View File

@ -16,12 +16,12 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
use std::{ptr, marker};
use libc;
use ffi;
use python::{Python, ToPythonPointer, PythonObject};
use conversion::ToPyObject;
use objects::{PyObject, PyType, PyString, PyModule, PyDict};
use std::{mem, ops, ptr, marker};
use err::{self, PyResult};
use super::{PythonBaseObject, PyRustObject, PyRustType};
@ -44,7 +44,7 @@ pub fn new_typebuilder_for_module<'p, T>(m: &PyModule<'p>, name: &str) -> PyRust
}
unsafe extern "C" fn disabled_tp_new_callback
(subtype: *mut ffi::PyTypeObject, args: *mut ffi::PyObject, kwds: *mut ffi::PyObject)
(_subtype: *mut ffi::PyTypeObject, _args: *mut ffi::PyObject, _kwds: *mut ffi::PyObject)
-> *mut ffi::PyObject {
ffi::PyErr_SetString(ffi::PyExc_TypeError,
b"Cannot initialize rust object from python.\0" as *const u8 as *const libc::c_char);
@ -173,15 +173,8 @@ pub trait TypeMember<'p, T> where T: PythonObject<'p> {
// TODO: does this cause trouble for coherence?
impl <'p, T, S> TypeMember<'p, T> for S where T: PythonObject<'p>, S: ToPyObject<'p> {
#[inline]
fn into_descriptor(self, ty: &PyType<'p>, name: &str) -> PyObject<'p> {
fn into_descriptor(self, ty: &PyType<'p>, _name: &str) -> PyObject<'p> {
self.into_py_object(ty.python()).into_object()
}
}
impl <'p, T> TypeMember<'p, T> for fn(&T) where T: PythonObject<'p> {
fn into_descriptor(self, ty: &PyType<'p>, name: &str) -> PyObject<'p> {
unimplemented!()
}
}