drop py3.4

This commit is contained in:
Nikolay Kim 2017-05-12 23:29:59 -07:00
parent 03a3817878
commit b2d49c3648
28 changed files with 41 additions and 211 deletions

View File

@ -1,6 +1,5 @@
language: python
python:
- "3.4"
- "3.5"
- "3.6"
env:

View File

@ -12,7 +12,7 @@ PyO3 is licensed under the [APACHE-2.0 license](http://opensource.org/licenses/A
Python is licensed under the [Python License](https://docs.python.org/2/license.html).
Supported Python versions:
* Python 3.4 to 3.6
* Python 3.5 and up
Supported Rust version:
* Rust 1.15.1 or later

View File

@ -25,7 +25,7 @@ impl fmt::Display for PythonVersion {
}
}
const MIN_MINOR: u8 = 4;
const MIN_MINOR: u8 = 5;
const CFG_KEY: &'static str = "py_sys_config";
@ -253,7 +253,6 @@ fn get_rustc_link_lib(version: &PythonVersion, _: &str, _: bool) -> Result<Strin
fn find_interpreter_and_get_config() -> Result<(PythonVersion, String, Vec<String>), String>
{
if let Some(sys_executable) = env::var_os("PYTHON_SYS_EXECUTABLE") {
println!("1111");
let interpreter_path = sys_executable.to_str()
.expect("Unable to get PYTHON_SYS_EXECUTABLE value");
let (interpreter_version, lines) = try!(get_config_from_interpreter(interpreter_path));
@ -271,7 +270,7 @@ fn find_interpreter_and_get_config() -> Result<(PythonVersion, String, Vec<Strin
{
let interpreter_path = "python";
let (interpreter_version, lines) = try!(get_config_from_interpreter(interpreter_path));
if MIN_MINOR < interpreter_version.minor.unwrap_or(0) {
if MIN_MINOR <= interpreter_version.minor.unwrap_or(0) {
return Ok((interpreter_version, interpreter_path.to_owned(), lines));
}
}

View File

@ -52,11 +52,8 @@ pub const CO_GENERATOR : c_int = 0x0020;
pub const CO_NOFREE : c_int = 0x0040;
/* The CO_COROUTINE flag is set for coroutine functions (defined with
``async def`` keywords) */
#[cfg(Py_3_5)]
pub const CO_COROUTINE : c_int = 0x0080;
#[cfg(Py_3_5)]
pub const CO_ITERABLE_COROUTINE : c_int = 0x0100;
#[cfg(Py_3_6)]
pub const CO_ASYNC_GENERATOR : c_int = 0x0200;
pub const CO_FUTURE_DIVISION : c_int = 0x2000;
@ -65,7 +62,6 @@ pub const CO_FUTURE_WITH_STATEMENT : c_int = 0x8000;
pub const CO_FUTURE_PRINT_FUNCTION : c_int = 0x10000;
pub const CO_FUTURE_UNICODE_LITERALS : c_int = 0x20000;
pub const CO_FUTURE_BARRY_AS_BDFL : c_int = 0x40000;
#[cfg(Py_3_5)]
pub const CO_FUTURE_GENERATOR_STOP : c_int = 0x80000;
pub const CO_MAXBLOCKS: usize = 20;

View File

@ -28,34 +28,29 @@ pub const FUTURE_PRINT_FUNCTION : &'static str = "print_function";
pub const FUTURE_UNICODE_LITERALS : &'static str = "unicode_literals";
#[cfg(not(Py_LIMITED_API))]
pub const FUTURE_BARRY_AS_BDFL : &'static str = "barry_as_FLUFL";
#[cfg(all(not(Py_LIMITED_API), Py_3_5))]
#[cfg(not(Py_LIMITED_API))]
pub const FUTURE_GENERATOR_STOP : &'static str = "generator_stop";
#[cfg(not(Py_LIMITED_API))]
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyNode_Compile(arg1: *mut _node,
arg2: *const c_char) -> *mut PyCodeObject;
pub fn PyNode_Compile(arg1: *mut _node, arg2: *const c_char) -> *mut PyCodeObject;
pub fn PyAST_CompileEx(_mod: *mut _mod,
filename: *const c_char,
flags: *mut PyCompilerFlags,
optimize: c_int, arena: *mut PyArena)
-> *mut PyCodeObject;
#[cfg(Py_3_4)]
optimize: c_int, arena: *mut PyArena) -> *mut PyCodeObject;
pub fn PyAST_CompileObject(_mod: *mut _mod,
filename: *mut PyObject,
flags: *mut PyCompilerFlags,
optimize: c_int, arena: *mut PyArena)
-> *mut PyCodeObject;
pub fn PyFuture_FromAST(_mod: *mut _mod,
filename: *const c_char)
-> *mut PyFutureFeatures;
#[cfg(Py_3_4)]
pub fn PyFuture_FromASTObject(_mod: *mut _mod,
filename: *mut PyObject)
-> *mut PyFutureFeatures;
#[cfg(Py_3_4)]
pub fn PyCompile_OpcodeStackEffect(opcode: c_int,
oparg: c_int) -> c_int;
optimize: c_int, arena: *mut PyArena) -> *mut PyCodeObject;
pub fn PyFuture_FromAST(_mod: *mut _mod, filename: *const c_char) -> *mut PyFutureFeatures;
pub fn PyFuture_FromASTObject(_mod: *mut _mod, filename: *mut PyObject) -> *mut PyFutureFeatures;
pub fn PyCompile_OpcodeStackEffect(
opcode: c_int, oparg: c_int) -> c_int;
}
pub const Py_single_input: c_int = 256;

View File

@ -30,11 +30,6 @@ pub struct PyFrameObject {
pub f_exc_type: *mut PyObject,
pub f_exc_value: *mut PyObject,
pub f_exc_traceback: *mut PyObject,
#[cfg(not(Py_3_4))]
pub f_tstate: *mut PyThreadState,
#[cfg(Py_3_4)]
pub f_gen: *mut PyObject,
pub f_lasti: c_int, /* Last instruction if called */
@ -45,7 +40,6 @@ pub struct PyFrameObject {
bytecode index. */
pub f_lineno: c_int, /* Current line number */
pub f_iblock: c_int, /* index in f_blockstack */
#[cfg(Py_3_4)]
pub f_executing: c_char, /* whether the frame is still executing */
pub f_blockstack: [PyTryBlock; CO_MAXBLOCKS], /* for try and loop blocks */
pub f_localsplus: [*mut PyObject; 1] /* locals+stack, dynamically sized */
@ -68,11 +62,9 @@ pub unsafe fn PyFrame_Check(op: *mut PyObject) -> c_int {
pub fn PyFrame_BlockPop(f: *mut PyFrameObject) -> *mut PyTryBlock;
pub fn PyFrame_LocalsToFast(f: *mut PyFrameObject, clear: c_int) -> ();
#[cfg(Py_3_4)]
pub fn PyFrame_FastToLocalsWithError(f: *mut PyFrameObject) -> c_int;
pub fn PyFrame_FastToLocals(f: *mut PyFrameObject) -> ();
pub fn PyFrame_ClearFreeList() -> c_int;
pub fn PyFrame_GetLineNumber(f: *mut PyFrameObject) -> c_int;
}

View File

@ -37,37 +37,23 @@ pub unsafe fn PyGen_CheckExact(op: *mut PyObject) -> c_int {
pub fn PyGen_NeedsFinalizing(op: *mut PyGenObject) -> c_int;
}
#[cfg(Py_3_5)]
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut PyCoro_Type: PyTypeObject;
}
#[cfg(Py_3_5)]
#[inline(always)]
pub unsafe fn PyCoro_Check(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, &mut PyCoro_Type)
}
#[cfg(not(Py_3_5))]
#[inline(always)]
pub unsafe fn PyCoro_Check(_op: *mut PyObject) -> c_int {
0
}
#[cfg(Py_3_5)]
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub static mut _PyCoroWrapper_Type: PyTypeObject;
}
#[cfg(Py_3_5)]
#[inline(always)]
pub unsafe fn PyCoroWrapper_Check(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, &mut _PyCoroWrapper_Type)
}
#[cfg(not(Py_3_5))]
#[inline(always)]
pub unsafe fn PyCoroWrapper_Check(_op: *mut PyObject) -> c_int {
0
}
#[cfg(Py_3_6)]
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {

View File

@ -1,4 +1,4 @@
use libc::c_int;
use std::os::raw::c_int;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyOS_InterruptOccurred() -> c_int;

View File

@ -2,7 +2,6 @@ use std::os::raw::{c_char, c_int, c_long};
use ffi::pyport::Py_ssize_t;
use ffi::object::PyObject;
use ffi::moduleobject::PyModuleDef;
#[cfg(Py_3_5)]
use ffi::methodobject::PyMethodDef;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
@ -36,14 +35,11 @@ use ffi::methodobject::PyMethodDef;
arg2: *const c_char,
arg3: *const c_char)
-> c_int;
#[cfg(Py_3_5)]
pub fn PyModule_SetDocString(arg1: *mut PyObject,
arg2: *const c_char)
-> c_int;
#[cfg(Py_3_5)]
pub fn PyModule_AddFunctions(arg1: *mut PyObject, arg2: *mut PyMethodDef)
-> c_int;
#[cfg(Py_3_5)]
pub fn PyModule_ExecDef(module: *mut PyObject, def: *mut PyModuleDef)
-> c_int;
}
@ -63,14 +59,12 @@ pub const PYTHON_ABI_VERSION: i32 = 3;
apiver: c_int) -> *mut PyObject;
#[cfg(not(py_sys_config="Py_TRACE_REFS"))]
#[cfg(Py_3_5)]
pub fn PyModule_FromDefAndSpec2(def: *mut PyModuleDef,
spec: *mut PyObject,
module_api_version: c_int)
-> *mut PyObject;
#[cfg(py_sys_config="Py_TRACE_REFS")]
#[cfg(Py_3_5)]
fn PyModule_FromDefAndSpec2TraceRefs(def: *mut PyModuleDef,
spec: *mut PyObject,
module_api_version: c_int)
@ -85,7 +79,6 @@ pub unsafe fn PyModule_Create2(module: *mut PyModuleDef,
}
#[cfg(py_sys_config="Py_TRACE_REFS")]
#[cfg(Py_3_5)]
#[inline]
pub unsafe fn PyModule_FromDefAndSpec2(def: *mut PyModuleDef,
spec: *mut PyObject,
@ -100,7 +93,6 @@ pub unsafe fn PyModule_Create(module: *mut PyModuleDef) -> *mut PyObject {
}
#[inline]
#[cfg(Py_3_5)]
pub unsafe fn PyModule_FromDefAndSpec(def: *mut PyModuleDef, spec: *mut PyObject) -> *mut PyObject {
PyModule_FromDefAndSpec2(def, spec, if cfg!(Py_LIMITED_API) { PYTHON_ABI_VERSION } else { PYTHON_API_VERSION })
}

View File

@ -27,10 +27,7 @@ pub unsafe fn PyModule_CheckExact(op : *mut PyObject) -> c_int {
pub fn PyModule_GetFilenameObject(arg1: *mut PyObject) -> *mut PyObject;
pub fn PyModule_GetDef(arg1: *mut PyObject) -> *mut PyModuleDef;
pub fn PyModule_GetState(arg1: *mut PyObject) -> *mut c_void;
#[cfg(Py_3_5)]
pub fn PyModuleDef_Init(arg1: *mut PyModuleDef) -> *mut PyObject;
#[cfg(Py_3_5)]
pub static mut PyModuleDef_Type: PyTypeObject;
}
@ -55,19 +52,15 @@ pub const PyModuleDef_HEAD_INIT: PyModuleDef_Base = PyModuleDef_Base {
#[repr(C)]
#[derive(Copy)]
#[cfg(Py_3_5)]
pub struct PyModuleDef_Slot {
pub slot: c_int,
pub value: *mut c_void,
}
#[cfg(Py_3_5)]
impl Clone for PyModuleDef_Slot {
fn clone(&self) -> PyModuleDef_Slot { *self }
}
#[cfg(Py_3_5)]
pub const Py_mod_create : c_int = 1;
#[cfg(Py_3_5)]
pub const Py_mod_exec : c_int = 2;
#[repr(C)]
@ -78,9 +71,6 @@ pub struct PyModuleDef {
pub m_doc: *const c_char,
pub m_size: Py_ssize_t,
pub m_methods: *mut PyMethodDef,
#[cfg(not(Py_3_5))]
pub m_reload: Option<inquiry>,
#[cfg(Py_3_5)]
pub m_slots: *mut PyModuleDef_Slot,
pub m_traverse: Option<traverseproc>,
pub m_clear: Option<inquiry>,
@ -90,20 +80,6 @@ impl Clone for PyModuleDef {
fn clone(&self) -> PyModuleDef { *self }
}
#[cfg(not(Py_3_5))]
pub const PyModuleDef_INIT: PyModuleDef = PyModuleDef {
m_base: PyModuleDef_HEAD_INIT,
m_name: 0 as *const _,
m_doc: 0 as *const _,
m_size: 0,
m_methods: 0 as *mut _,
m_reload: None,
m_traverse: None,
m_clear: None,
m_free: None
};
#[cfg(Py_3_5)]
pub const PyModuleDef_INIT: PyModuleDef = PyModuleDef {
m_base: PyModuleDef_HEAD_INIT,
m_name: 0 as *const _,

View File

@ -277,9 +277,7 @@ mod typeobject {
pub nb_inplace_floor_divide: Option<object::binaryfunc>,
pub nb_inplace_true_divide: Option<object::binaryfunc>,
pub nb_index: Option<object::unaryfunc>,
#[cfg(Py_3_5)]
pub nb_matrix_multiply: Option<object::binaryfunc>,
#[cfg(Py_3_5)]
pub nb_inplace_matrix_multiply: Option<object::binaryfunc>,
}
impl Clone for PyNumberMethods {
@ -335,10 +333,6 @@ mod typeobject {
}
}
#[cfg(not(Py_3_5))]
pub const PyNumberMethods_INIT: PyNumberMethods = py_number_methods_init!();
#[cfg(Py_3_5)]
pub const PyNumberMethods_INIT: PyNumberMethods = py_number_methods_init! {
nb_matrix_multiply: None,
nb_inplace_matrix_multiply: None,
@ -396,21 +390,17 @@ mod typeobject {
};
#[repr(C)]
#[derive(Copy)]
#[cfg(Py_3_5)]
pub struct PyAsyncMethods {
pub am_await: Option<object::unaryfunc>,
pub am_aiter: Option<object::unaryfunc>,
pub am_anext: Option<object::unaryfunc>,
}
#[cfg(Py_3_5)]
impl Clone for PyAsyncMethods {
#[inline] fn clone(&self) -> Self { *self }
}
#[cfg(Py_3_5)]
impl Default for PyAsyncMethods {
#[inline] fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[cfg(Py_3_5)]
pub const PyAsyncMethods_INIT : PyAsyncMethods = PyAsyncMethods {
am_await: None,
am_aiter: None,
@ -444,10 +434,7 @@ mod typeobject {
pub tp_print: Option<object::printfunc>,
pub tp_getattr: Option<object::getattrfunc>,
pub tp_setattr: Option<object::setattrfunc>,
#[cfg(Py_3_5)]
pub tp_as_async: *mut PyAsyncMethods,
#[cfg(not(Py_3_5))]
pub tp_reserved: *mut c_void,
pub tp_repr: Option<object::reprfunc>,
pub tp_as_number: *mut PyNumberMethods,
pub tp_as_sequence: *mut PySequenceMethods,
@ -486,7 +473,6 @@ mod typeobject {
pub tp_weaklist: *mut ffi::object::PyObject,
pub tp_del: Option<ffi::object::destructor>,
pub tp_version_tag: c_uint,
#[cfg(Py_3_4)]
pub tp_finalize: Option<ffi::object::destructor>,
#[cfg(py_sys_config="COUNT_ALLOCS")]
pub tp_allocs: Py_ssize_t,
@ -584,28 +570,15 @@ mod typeobject {
}
}
#[cfg(Py_3_5)]
pub const PyTypeObject_INIT: PyTypeObject = py_type_object_init_with_count_allocs!(
tp_as_async,
tp_finalize: None,
);
#[cfg(all(Py_3_4, not(Py_3_5)))]
pub const PyTypeObject_INIT: PyTypeObject = py_type_object_init_with_count_allocs!(
tp_reserved,
tp_finalize: None,
);
#[cfg(not(Py_3_4))]
pub const PyTypeObject_INIT: PyTypeObject = py_type_object_init_with_count_allocs!(
tp_reserved,
);
#[repr(C)]
#[derive(Copy)]
pub struct PyHeapTypeObject {
pub ht_type: PyTypeObject,
#[cfg(Py_3_5)]
pub as_async: PyAsyncMethods,
pub as_number: PyNumberMethods,
pub as_mapping: PyMappingMethods,
@ -665,11 +638,9 @@ impl Default for PyType_Spec {
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyType_FromSpec(arg1: *mut PyType_Spec) -> *mut PyObject;
//#[cfg(Py_3_3)]
pub fn PyType_FromSpecWithBases(arg1: *mut PyType_Spec, arg2: *mut PyObject)
-> *mut PyObject;
#[cfg(Py_3_4)]
pub fn PyType_GetSlot(arg1: *mut PyTypeObject, arg2: c_int)
-> *mut c_void;
}
@ -756,10 +727,8 @@ pub unsafe fn PyType_CheckExact(op: *mut PyObject) -> c_int {
pub fn PyObject_Not(arg1: *mut PyObject) -> c_int;
pub fn PyCallable_Check(arg1: *mut PyObject) -> c_int;
pub fn PyObject_ClearWeakRefs(arg1: *mut PyObject) -> ();
#[cfg(Py_3_4)]
#[cfg(not(Py_LIMITED_API))]
pub fn PyObject_CallFinalizer(arg1: *mut PyObject) -> ();
#[cfg(Py_3_4)]
#[cfg(not(Py_LIMITED_API))]
pub fn PyObject_CallFinalizerFromDealloc(arg1: *mut PyObject) -> c_int;

View File

@ -42,7 +42,7 @@ pub unsafe fn PyObject_Length(o: *mut PyObject) -> Py_ssize_t {
}
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
#[cfg(all(not(Py_LIMITED_API), Py_3_4))]
#[cfg(not(Py_LIMITED_API))]
pub fn PyObject_LengthHint(o: *mut PyObject, arg1: Py_ssize_t)
-> Py_ssize_t;
@ -130,7 +130,6 @@ pub unsafe fn PyIter_Check(o: *mut PyObject) -> c_int {
-> *mut PyObject;
pub fn PyNumber_Multiply(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
#[cfg(Py_3_5)]
pub fn PyNumber_MatrixMultiply(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_FloorDivide(o1: *mut PyObject, o2: *mut PyObject)
@ -177,7 +176,6 @@ pub unsafe fn PyIndex_Check(o: *mut PyObject) -> c_int {
-> *mut PyObject;
pub fn PyNumber_InPlaceMultiply(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
#[cfg(Py_3_5)]
pub fn PyNumber_InPlaceMatrixMultiply(o1: *mut PyObject, o2: *mut PyObject)
-> *mut PyObject;
pub fn PyNumber_InPlaceFloorDivide(o1: *mut PyObject, o2: *mut PyObject)

View File

@ -5,13 +5,12 @@ use ffi::object::*;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyObject_Malloc(size: size_t) -> *mut c_void;
#[cfg(Py_3_5)]
pub fn PyObject_Calloc(nelem: size_t, elsize: size_t) -> *mut c_void;
pub fn PyObject_Realloc(ptr: *mut c_void, new_size: size_t)
-> *mut c_void;
pub fn PyObject_Free(ptr: *mut c_void) -> ();
#[cfg(all(not(Py_LIMITED_API), Py_3_4))]
#[cfg(not(Py_LIMITED_API))]
pub fn _Py_GetAllocatedBlocks() -> Py_ssize_t;
pub fn PyObject_Init(arg1: *mut PyObject, arg2: *mut PyTypeObject)
-> *mut PyObject;
@ -26,7 +25,7 @@ use ffi::object::*;
#[repr(C)]
#[derive(Copy)]
#[cfg(all(not(Py_LIMITED_API), Py_3_4))]
#[cfg(not(Py_LIMITED_API))]
pub struct PyObjectArenaAllocator {
pub ctx: *mut c_void,
pub alloc: Option<extern "C" fn(ctx: *mut c_void,
@ -36,15 +35,15 @@ pub struct PyObjectArenaAllocator {
ptr: *mut c_void,
size: size_t) -> ()>,
}
#[cfg(all(not(Py_LIMITED_API), Py_3_4))]
#[cfg(not(Py_LIMITED_API))]
impl Clone for PyObjectArenaAllocator {
#[inline] fn clone(&self) -> Self { *self }
}
#[cfg(all(not(Py_LIMITED_API), Py_3_4))]
#[cfg(not(Py_LIMITED_API))]
impl Default for PyObjectArenaAllocator {
#[inline] fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[cfg(all(not(Py_LIMITED_API), Py_3_4))]
#[cfg(not(Py_LIMITED_API))]
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyObject_GetArenaAllocator(allocator: *mut PyObjectArenaAllocator)
-> ();
@ -75,7 +74,7 @@ pub unsafe fn PyObject_IS_GC(o : *mut PyObject) -> c_int {
#[cfg(not(Py_LIMITED_API))]
pub fn _PyObject_GC_Malloc(size: size_t) -> *mut PyObject;
#[cfg(all(not(Py_LIMITED_API), Py_3_5))]
#[cfg(not(Py_LIMITED_API))]
pub fn _PyObject_GC_Calloc(size: size_t) -> *mut PyObject;
pub fn _PyObject_GC_New(arg1: *mut PyTypeObject) -> *mut PyObject;
pub fn _PyObject_GC_NewVar(arg1: *mut PyTypeObject, arg2: Py_ssize_t)

View File

@ -1,4 +1,4 @@
use libc::c_int;
use std::os::raw::c_int;
#[cfg(not(Py_LIMITED_API))]
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
@ -17,7 +17,6 @@ use libc::c_int;
pub static mut Py_NoUserSiteDirectory: c_int;
pub static mut Py_UnbufferedStdioFlag: c_int;
pub static mut Py_HashRandomizationFlag: c_int;
#[cfg(Py_3_4)]
pub static mut Py_IsolatedFlag: c_int;
#[cfg(all(Py_3_6, windows))]
pub static mut Py_LegacyWindowsStdioFlag: c_int;

View File

@ -127,7 +127,6 @@ pub unsafe fn PyExceptionInstance_Class(x: *mut PyObject) -> *mut PyObject {
pub fn PyErr_SetFromErrnoWithFilenameObject(arg1: *mut PyObject,
arg2: *mut PyObject)
-> *mut PyObject;
#[cfg(Py_3_4)]
pub fn PyErr_SetFromErrnoWithFilenameObjects(arg1: *mut PyObject,
arg2: *mut PyObject,
arg3: *mut PyObject)

View File

@ -1,10 +1,9 @@
use libc::{c_void, size_t};
use std::os::raw::c_void;
use libc::size_t;
#[cfg(Py_3_4)]
#[cfg(not(Py_LIMITED_API))]
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyMem_RawMalloc(size: size_t) -> *mut c_void;
#[cfg(Py_3_5)]
pub fn PyMem_RawCalloc(nelem: size_t, elsize: size_t)
-> *mut c_void;
pub fn PyMem_RawRealloc(ptr: *mut c_void, new_size: size_t)
@ -14,14 +13,12 @@ use libc::{c_void, size_t};
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
pub fn PyMem_Malloc(size: size_t) -> *mut c_void;
#[cfg(Py_3_5)]
pub fn PyMem_Calloc(nelem: size_t, elsize: size_t) -> *mut c_void;
pub fn PyMem_Realloc(ptr: *mut c_void, new_size: size_t)
-> *mut c_void;
pub fn PyMem_Free(ptr: *mut c_void) -> ();
}
#[cfg(Py_3_4)]
#[cfg(not(Py_LIMITED_API))]
#[repr(C)]
#[derive(Copy, Clone)]
@ -33,24 +30,7 @@ pub enum PyMemAllocatorDomain {
#[repr(C)]
#[derive(Copy, Clone)]
#[cfg(all(Py_3_4, not(Py_3_5), not(Py_LIMITED_API)))]
pub struct PyMemAllocator {
pub ctx: *mut c_void,
pub malloc: Option<extern "C" fn(ctx: *mut c_void,
size: size_t)
-> *mut c_void>,
pub realloc: Option<extern "C" fn(ctx: *mut c_void,
ptr: *mut c_void,
new_size: size_t)
-> *mut c_void>,
pub free: Option<extern "C" fn(ctx: *mut c_void,
ptr: *mut c_void)
-> ()>,
}
#[repr(C)]
#[derive(Copy, Clone)]
#[cfg(all(Py_3_5, not(Py_LIMITED_API)))]
#[cfg(not(Py_LIMITED_API))]
pub struct PyMemAllocatorEx {
pub ctx: *mut c_void,
pub malloc: Option<extern "C" fn(ctx: *mut c_void,
@ -69,19 +49,10 @@ pub struct PyMemAllocatorEx {
-> ()>,
}
#[cfg(Py_3_4)]
#[cfg(not(Py_LIMITED_API))]
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
#[cfg(not(Py_3_5))]
pub fn PyMem_GetAllocator(domain: PyMemAllocatorDomain,
allocator: *mut PyMemAllocator) -> ();
#[cfg(not(Py_3_5))]
pub fn PyMem_SetAllocator(domain: PyMemAllocatorDomain,
allocator: *mut PyMemAllocator) -> ();
#[cfg(Py_3_5)]
pub fn PyMem_GetAllocator(domain: PyMemAllocatorDomain,
allocator: *mut PyMemAllocatorEx) -> ();
#[cfg(Py_3_5)]
pub fn PyMem_SetAllocator(domain: PyMemAllocatorDomain,
allocator: *mut PyMemAllocatorEx) -> ();
pub fn PyMem_SetupDebugHooks() -> ();

View File

@ -51,7 +51,6 @@ pub enum _mod {}
filename: *const c_char,
flags: *mut PyCompilerFlags)
-> c_int;
#[cfg(Py_3_4)]
pub fn PyRun_InteractiveOneObject(fp: *mut FILE, filename: *mut PyObject,
flags: *mut PyCompilerFlags)
-> c_int;
@ -64,7 +63,6 @@ pub enum _mod {}
start: c_int,
flags: *mut PyCompilerFlags,
arena: *mut PyArena) -> *mut _mod;
#[cfg(Py_3_4)]
pub fn PyParser_ASTFromStringObject(s: *const c_char,
filename: *mut PyObject,
start: c_int,
@ -80,7 +78,6 @@ pub enum _mod {}
flags: *mut PyCompilerFlags,
errcode: *mut c_int,
arena: *mut PyArena) -> *mut _mod;
#[cfg(Py_3_4)]
pub fn PyParser_ASTFromFileObject(fp: *mut FILE, filename: *mut PyObject,
enc: *const c_char,
start: c_int,
@ -156,7 +153,6 @@ pub unsafe fn Py_CompileStringFlags(string: *const c_char, p: *const c_char, s:
flags: *mut PyCompilerFlags,
optimize: c_int) -> *mut PyObject;
#[cfg(not(Py_LIMITED_API))]
#[cfg(Py_3_4)]
pub fn Py_CompileStringObject(str: *const c_char,
filename: *mut PyObject,
start: c_int,
@ -166,7 +162,6 @@ pub unsafe fn Py_CompileStringFlags(string: *const c_char, p: *const c_char, s:
filename: *const c_char,
start: c_int) -> *mut symtable;
#[cfg(not(Py_LIMITED_API))]
#[cfg(Py_3_4)]
pub fn Py_SymtableStringObject(str: *const c_char,
filename: *mut PyObject,
start: c_int)

View File

@ -1,4 +1,5 @@
use libc::{c_char, c_int, wchar_t};
use std::os::raw::{c_char, c_int};
use libc::wchar_t;
use ffi::object::PyObject;
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {

View File

@ -1,4 +1,4 @@
use libc::c_int;
use std::os::raw::c_int;
pub const Py_mp_ass_subscript : c_int = 3;
pub const Py_mp_length : c_int = 4;
@ -72,16 +72,9 @@ pub const Py_tp_traverse : c_int = 71;
pub const Py_tp_members : c_int = 72;
pub const Py_tp_getset : c_int = 73;
pub const Py_tp_free : c_int = 74;
#[cfg(Py_3_5)]
pub const Py_nb_matrix_multiply : c_int = 75;
#[cfg(Py_3_5)]
pub const Py_nb_inplace_matrix_multiply : c_int = 76;
#[cfg(Py_3_5)]
pub const Py_am_await : c_int = 77;
#[cfg(Py_3_5)]
pub const Py_am_aiter : c_int = 78;
#[cfg(Py_3_5)]
pub const Py_am_anext : c_int = 79;
#[cfg(Py_3_5)]
pub const Py_tp_finalize : c_int = 80;

View File

@ -4,7 +4,7 @@ use std;
use std::{mem, str, char, ptr};
use std::ascii::AsciiExt;
use std::borrow::Cow;
use libc::c_char;
use std::os::raw::c_char;
use ffi;
use python::{Python, PythonObject, PyClone, ToPythonPointer, PythonObjectDowncastError};
use super::{exc, PyObject};

View File

@ -18,7 +18,7 @@
//! This module contains the python exception types.
use libc::c_char;
use std::os::raw::c_char;
use std::{self, mem, ops};
use std::ffi::CStr;
use ffi;

View File

@ -18,7 +18,7 @@
use std;
use ffi;
use libc::c_char;
use std::os::raw::c_char;
use python::{Python, PythonObject, PyDrop};
use objectprotocol::ObjectProtocol;
use conversion::ToPyObject;

View File

@ -19,7 +19,7 @@
extern crate num_traits;
use self::num_traits::cast::cast;
use libc::{c_long, c_double};
use std::os::raw::{c_long, c_double};
use python::{Python, PythonObject, PyClone};
use err::{self, PyResult, PyErr};
use super::object::PyObject;

View File

@ -1,7 +1,7 @@
// Copyright (c) 2017-present PyO3 Project and Contributors
use std::mem;
use libc::c_long;
use std::os::raw::c_long;
use super::object::PyObject;
use python::{Python, PythonObject, ToPythonPointer, PyClone, PyDrop};
use err::{self, PyErr, PyResult};

View File

@ -20,7 +20,7 @@ use std;
use std::{mem, str, char};
use std::ascii::AsciiExt;
use std::borrow::Cow;
use libc::c_char;
use std::os::raw::c_char;
use ffi;
use python::{Python, PythonObject, PyClone, ToPythonPointer, PythonObjectDowncastError};
use super::{exc, PyObject};

View File

@ -1,3 +1,5 @@
// Copyright (c) 2017-present PyO3 Project and Contributors
use ffi;
pub fn type_error_to_unit(py: ::Python, e: ::PyErr) -> ::PyResult<()> {

View File

@ -19,7 +19,7 @@
use ffi;
use std::{mem, isize, ptr};
use std::ffi::CString;
use libc::{c_char, c_int};
use std::os::raw::{c_char, c_int};
use python::{Python, PythonObject};
use conversion::ToPyObject;
use objects::PyObject;
@ -74,7 +74,6 @@ macro_rules! py_class_type_object_flags {
pub const TPFLAGS_DEFAULT : ::libc::c_ulong = ffi::Py_TPFLAGS_DEFAULT;
#[cfg(Py_3_5)]
#[macro_export]
#[doc(hidden)]
macro_rules! py_class_type_object_dynamic_init {
@ -104,35 +103,6 @@ macro_rules! py_class_type_object_dynamic_init {
}
}
#[cfg(not(Py_3_5))]
#[macro_export]
#[doc(hidden)]
macro_rules! py_class_type_object_dynamic_init {
// initialize those fields of PyTypeObject that we couldn't initialize statically
($class: ident, $py:ident, $type_object:ident, $module_name: ident,
/* slots: */ {
$type_slots:tt
$as_async:tt
$as_number:tt
$as_sequence:tt
$as_mapping:tt
$as_buffer:tt
$setdelitem:tt
}
) => {
unsafe {
$type_object.tp_name = $crate::py_class::slots::build_tp_name($module_name, stringify!($class));
$type_object.tp_basicsize = <$class as $crate::py_class::BaseObject>::size()
as $crate::_detail::ffi::Py_ssize_t;
}
// call slot macros outside of unsafe block
*(unsafe { &mut $type_object.tp_as_sequence }) = py_class_as_sequence!($as_sequence);
*(unsafe { &mut $type_object.tp_as_number }) = py_class_as_number!($as_number);
*(unsafe { &mut $type_object.tp_as_buffer }) = py_class_as_buffer!($as_buffer);
py_class_as_mapping!($type_object, $as_mapping, $setdelitem);
}
}
pub fn build_tp_name(module_name: Option<&str>, type_name: &str) -> *mut c_char {
let name = match module_name {
Some(module_name) => CString::new(format!("{}.{}", module_name, type_name)),
@ -210,7 +180,6 @@ macro_rules! py_class_as_number {
}}
}
#[cfg(Py_3_5)]
#[macro_export]
#[doc(hidden)]
macro_rules! py_class_as_async {

View File

@ -19,7 +19,7 @@
use std;
use std::ffi::CString;
use std::marker::PhantomData;
use libc::c_int;
use std::os::raw::c_int;
use ffi;
use objects::{PyObject, PyType, PyBool, PyDict, PyModule};
use err::{self, PyErr, PyResult};