ffi: many fixes caught by pyo3-ffi-check

This commit is contained in:
David Hewitt 2022-06-02 16:30:07 +01:00
parent 62e110cdcf
commit 78cdc6d6ad
11 changed files with 340 additions and 281 deletions

View File

@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add macro `append_to_inittab`. [#2377](https://github.com/PyO3/pyo3/pull/2377) - Add macro `append_to_inittab`. [#2377](https://github.com/PyO3/pyo3/pull/2377)
- Add FFI definition `PyFrame_GetCode`. [#2406](https://github.com/PyO3/pyo3/pull/2406) - Add FFI definition `PyFrame_GetCode`. [#2406](https://github.com/PyO3/pyo3/pull/2406)
- Added `PyCode` and `PyFrame` high level objects. [#2408](https://github.com/PyO3/pyo3/pull/2408) - Added `PyCode` and `PyFrame` high level objects. [#2408](https://github.com/PyO3/pyo3/pull/2408)
- Add FFI definitions `Py_fstring_input`, `sendfunc`, and `_PyErr_StackItem`. [#2423](https://github.com/PyO3/pyo3/pull/2423)
### Changed ### Changed
@ -40,6 +41,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix compile failure when using `#[pyo3(from_py_with = "pouf")]` in on a field in a `#[derive(FromPyObject)]` struct. [#2414](https://github.com/PyO3/pyo3/pull/2414) - Fix compile failure when using `#[pyo3(from_py_with = "pouf")]` in on a field in a `#[derive(FromPyObject)]` struct. [#2414](https://github.com/PyO3/pyo3/pull/2414)
- Fix FFI definitions `_PyDateTime_BaseTime` lacking leading underscores in their names. [#2421](https://github.com/PyO3/pyo3/pull/2421) - Fix FFI definitions `_PyDateTime_BaseTime` lacking leading underscores in their names. [#2421](https://github.com/PyO3/pyo3/pull/2421)
- Remove FFI definition `PyArena` on Python 3.10 and up. [#2421](https://github.com/PyO3/pyo3/pull/2421) - Remove FFI definition `PyArena` on Python 3.10 and up. [#2421](https://github.com/PyO3/pyo3/pull/2421)
- Fix FFI definition `PyCompilerFlags` missing member `cf_feature_version` on Python 3.8 and up. [#2423](https://github.com/PyO3/pyo3/pull/2423)
- Fix FFI definition `PyAsyncMethods` missing member `am_send` on Python 3.10 and up. [#2423](https://github.com/PyO3/pyo3/pull/2423)
- Fix FFI definition `PyGenObject` having multiple incorrect members on various Python versions. [#2423](https://github.com/PyO3/pyo3/pull/2423)
- Fix FFI definition `PySyntaxErrorObject` missing members `end_lineno` and `end_offset` on Python 3.10 and up. [#2423](https://github.com/PyO3/pyo3/pull/2423)
- Fix FFI definition `PyHeapTypeObject` missing member `ht_module` on Python 3.9 and up. [#2423](https://github.com/PyO3/pyo3/pull/2423)
## [0.16.5] - 2022-05-15 ## [0.16.5] - 2022-05-15

View File

@ -5,4 +5,6 @@ pub const Py_file_input: c_int = 257;
pub const Py_eval_input: c_int = 258; pub const Py_eval_input: c_int = 258;
#[cfg(Py_3_8)] #[cfg(Py_3_8)]
pub const Py_func_type_input: c_int = 345; pub const Py_func_type_input: c_int = 345;
// skipped Py_fstring_input
#[cfg(Py_3_9)]
pub const Py_fstring_input: c_int = 800;

View File

@ -20,7 +20,14 @@ use std::os::raw::c_int;
// skipped non-limited PyCF_ALLOW_TOP_LEVEL_AWAIT // skipped non-limited PyCF_ALLOW_TOP_LEVEL_AWAIT
// skipped non-limited PyCF_COMPILE_MASK // skipped non-limited PyCF_COMPILE_MASK
// skipped non-limited PyCompilerFlags #[repr(C)]
#[derive(Copy, Clone)]
pub struct PyCompilerFlags {
pub cf_flags: c_int,
#[cfg(Py_3_8)]
pub cf_feature_version: c_int,
}
// skipped non-limited _PyCompilerFlags_INIT // skipped non-limited _PyCompilerFlags_INIT
#[repr(C)] #[repr(C)]

View File

@ -1,6 +1,6 @@
use crate::object::*; use crate::object::*;
use crate::pyport::Py_ssize_t; use crate::pyport::Py_ssize_t;
use crate::PyFrameObject; use crate::{PyFrameObject, _PyErr_StackItem};
use std::os::raw::c_int; use std::os::raw::c_int;
#[repr(C)] #[repr(C)]
@ -13,9 +13,13 @@ pub struct PyGenObject {
pub ob_refcnt: Py_ssize_t, pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject, pub ob_type: *mut PyTypeObject,
pub gi_frame: *mut PyFrameObject, pub gi_frame: *mut PyFrameObject,
#[cfg(not(Py_3_10))]
pub gi_running: c_int, pub gi_running: c_int,
pub gi_code: *mut PyObject, pub gi_code: *mut PyObject,
pub gi_weakreflist: *mut PyObject, pub gi_weakreflist: *mut PyObject,
pub gi_name: *mut PyObject,
pub gi_qualname: *mut PyObject,
pub gi_exc_state: _PyErr_StackItem,
} }
#[cfg_attr(windows, link(name = "pythonXY"))] #[cfg_attr(windows, link(name = "pythonXY"))]

View File

@ -11,6 +11,7 @@ pub(crate) mod dictobject;
// skipped fileobject.h // skipped fileobject.h
// skipped fileutils.h // skipped fileutils.h
pub(crate) mod frameobject; pub(crate) mod frameobject;
pub(crate) mod genobject;
pub(crate) mod import; pub(crate) mod import;
#[cfg(all(Py_3_8, not(PyPy)))] #[cfg(all(Py_3_8, not(PyPy)))]
pub(crate) mod initconfig; pub(crate) mod initconfig;
@ -18,6 +19,7 @@ pub(crate) mod initconfig;
pub(crate) mod listobject; pub(crate) mod listobject;
pub(crate) mod object; pub(crate) mod object;
pub(crate) mod pydebug; pub(crate) mod pydebug;
pub(crate) mod pyerrors;
#[cfg(all(Py_3_8, not(PyPy)))] #[cfg(all(Py_3_8, not(PyPy)))]
pub(crate) mod pylifecycle; pub(crate) mod pylifecycle;
pub(crate) mod pymem; pub(crate) mod pymem;
@ -37,12 +39,14 @@ pub use self::compile::*;
#[cfg(not(PyPy))] #[cfg(not(PyPy))]
pub use self::dictobject::*; pub use self::dictobject::*;
pub use self::frameobject::*; pub use self::frameobject::*;
pub use self::genobject::*;
pub use self::import::*; pub use self::import::*;
#[cfg(all(Py_3_8, not(PyPy)))] #[cfg(all(Py_3_8, not(PyPy)))]
pub use self::initconfig::*; pub use self::initconfig::*;
pub use self::listobject::*; pub use self::listobject::*;
pub use self::object::*; pub use self::object::*;
pub use self::pydebug::*; pub use self::pydebug::*;
pub use self::pyerrors::*;
#[cfg(all(Py_3_8, not(PyPy)))] #[cfg(all(Py_3_8, not(PyPy)))]
pub use self::pylifecycle::*; pub use self::pylifecycle::*;
pub use self::pymem::*; pub use self::pymem::*;

View File

@ -1,5 +1,7 @@
use crate::PyObject; use crate::object;
use std::os::raw::c_int; use crate::{PyObject, Py_ssize_t};
use std::mem;
use std::os::raw::{c_char, c_int, c_uint, c_ulong, c_void};
// skipped _Py_NewReference // skipped _Py_NewReference
// skipped _Py_ForgetReference // skipped _Py_ForgetReference
@ -118,209 +120,208 @@ pub type vectorcallfunc = unsafe extern "C" fn(
kwnames: *mut PyObject, kwnames: *mut PyObject,
) -> *mut PyObject; ) -> *mut PyObject;
mod typeobject { #[repr(C)]
use crate::object; #[derive(Copy, Clone)]
use crate::{PyObject, Py_ssize_t}; pub struct PyNumberMethods {
use std::mem; pub nb_add: Option<object::binaryfunc>,
use std::os::raw::{c_char, c_int, c_uint, c_ulong, c_void}; pub nb_subtract: Option<object::binaryfunc>,
pub nb_multiply: Option<object::binaryfunc>,
pub nb_remainder: Option<object::binaryfunc>,
pub nb_divmod: Option<object::binaryfunc>,
pub nb_power: Option<object::ternaryfunc>,
pub nb_negative: Option<object::unaryfunc>,
pub nb_positive: Option<object::unaryfunc>,
pub nb_absolute: Option<object::unaryfunc>,
pub nb_bool: Option<object::inquiry>,
pub nb_invert: Option<object::unaryfunc>,
pub nb_lshift: Option<object::binaryfunc>,
pub nb_rshift: Option<object::binaryfunc>,
pub nb_and: Option<object::binaryfunc>,
pub nb_xor: Option<object::binaryfunc>,
pub nb_or: Option<object::binaryfunc>,
pub nb_int: Option<object::unaryfunc>,
pub nb_reserved: *mut c_void,
pub nb_float: Option<object::unaryfunc>,
pub nb_inplace_add: Option<object::binaryfunc>,
pub nb_inplace_subtract: Option<object::binaryfunc>,
pub nb_inplace_multiply: Option<object::binaryfunc>,
pub nb_inplace_remainder: Option<object::binaryfunc>,
pub nb_inplace_power: Option<object::ternaryfunc>,
pub nb_inplace_lshift: Option<object::binaryfunc>,
pub nb_inplace_rshift: Option<object::binaryfunc>,
pub nb_inplace_and: Option<object::binaryfunc>,
pub nb_inplace_xor: Option<object::binaryfunc>,
pub nb_inplace_or: Option<object::binaryfunc>,
pub nb_floor_divide: Option<object::binaryfunc>,
pub nb_true_divide: Option<object::binaryfunc>,
pub nb_inplace_floor_divide: Option<object::binaryfunc>,
pub nb_inplace_true_divide: Option<object::binaryfunc>,
pub nb_index: Option<object::unaryfunc>,
pub nb_matrix_multiply: Option<object::binaryfunc>,
pub nb_inplace_matrix_multiply: Option<object::binaryfunc>,
}
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone)] #[derive(Clone)]
pub struct PyNumberMethods { pub struct PySequenceMethods {
pub nb_add: Option<object::binaryfunc>, pub sq_length: Option<object::lenfunc>,
pub nb_subtract: Option<object::binaryfunc>, pub sq_concat: Option<object::binaryfunc>,
pub nb_multiply: Option<object::binaryfunc>, pub sq_repeat: Option<object::ssizeargfunc>,
pub nb_remainder: Option<object::binaryfunc>, pub sq_item: Option<object::ssizeargfunc>,
pub nb_divmod: Option<object::binaryfunc>, pub was_sq_slice: *mut c_void,
pub nb_power: Option<object::ternaryfunc>, pub sq_ass_item: Option<object::ssizeobjargproc>,
pub nb_negative: Option<object::unaryfunc>, pub was_sq_ass_slice: *mut c_void,
pub nb_positive: Option<object::unaryfunc>, pub sq_contains: Option<object::objobjproc>,
pub nb_absolute: Option<object::unaryfunc>, pub sq_inplace_concat: Option<object::binaryfunc>,
pub nb_bool: Option<object::inquiry>, pub sq_inplace_repeat: Option<object::ssizeargfunc>,
pub nb_invert: Option<object::unaryfunc>, }
pub nb_lshift: Option<object::binaryfunc>,
pub nb_rshift: Option<object::binaryfunc>,
pub nb_and: Option<object::binaryfunc>,
pub nb_xor: Option<object::binaryfunc>,
pub nb_or: Option<object::binaryfunc>,
pub nb_int: Option<object::unaryfunc>,
pub nb_reserved: *mut c_void,
pub nb_float: Option<object::unaryfunc>,
pub nb_inplace_add: Option<object::binaryfunc>,
pub nb_inplace_subtract: Option<object::binaryfunc>,
pub nb_inplace_multiply: Option<object::binaryfunc>,
pub nb_inplace_remainder: Option<object::binaryfunc>,
pub nb_inplace_power: Option<object::ternaryfunc>,
pub nb_inplace_lshift: Option<object::binaryfunc>,
pub nb_inplace_rshift: Option<object::binaryfunc>,
pub nb_inplace_and: Option<object::binaryfunc>,
pub nb_inplace_xor: Option<object::binaryfunc>,
pub nb_inplace_or: Option<object::binaryfunc>,
pub nb_floor_divide: Option<object::binaryfunc>,
pub nb_true_divide: Option<object::binaryfunc>,
pub nb_inplace_floor_divide: Option<object::binaryfunc>,
pub nb_inplace_true_divide: Option<object::binaryfunc>,
pub nb_index: Option<object::unaryfunc>,
pub nb_matrix_multiply: Option<object::binaryfunc>,
pub nb_inplace_matrix_multiply: Option<object::binaryfunc>,
}
#[repr(C)] #[repr(C)]
#[derive(Clone)] #[derive(Clone, Default)]
pub struct PySequenceMethods { pub struct PyMappingMethods {
pub sq_length: Option<object::lenfunc>, pub mp_length: Option<object::lenfunc>,
pub sq_concat: Option<object::binaryfunc>, pub mp_subscript: Option<object::binaryfunc>,
pub sq_repeat: Option<object::ssizeargfunc>, pub mp_ass_subscript: Option<object::objobjargproc>,
pub sq_item: Option<object::ssizeargfunc>, }
pub was_sq_slice: *mut c_void,
pub sq_ass_item: Option<object::ssizeobjargproc>,
pub was_sq_ass_slice: *mut c_void,
pub sq_contains: Option<object::objobjproc>,
pub sq_inplace_concat: Option<object::binaryfunc>,
pub sq_inplace_repeat: Option<object::ssizeargfunc>,
}
#[repr(C)] #[cfg(Py_3_10)]
#[derive(Clone, Default)] pub type sendfunc = unsafe extern "C" fn(
pub struct PyMappingMethods { iter: *mut PyObject,
pub mp_length: Option<object::lenfunc>, value: *mut PyObject,
pub mp_subscript: Option<object::binaryfunc>, result: *mut *mut PyObject,
pub mp_ass_subscript: Option<object::objobjargproc>, ) -> object::PySendResult;
}
// skipped PySendResult #[repr(C)]
#[derive(Clone, Default)]
pub struct PyAsyncMethods {
pub am_await: Option<object::unaryfunc>,
pub am_aiter: Option<object::unaryfunc>,
pub am_anext: Option<object::unaryfunc>,
#[cfg(Py_3_10)]
pub am_send: Option<sendfunc>,
}
#[repr(C)] #[repr(C)]
#[derive(Clone, Default)] #[derive(Clone, Default)]
pub struct PyAsyncMethods { pub struct PyBufferProcs {
pub am_await: Option<object::unaryfunc>, pub bf_getbuffer: Option<crate::getbufferproc>,
pub am_aiter: Option<object::unaryfunc>, pub bf_releasebuffer: Option<crate::releasebufferproc>,
pub am_anext: Option<object::unaryfunc>, }
}
#[repr(C)] pub type printfunc =
#[derive(Clone, Default)] unsafe extern "C" fn(arg1: *mut PyObject, arg2: *mut ::libc::FILE, arg3: c_int) -> c_int;
pub struct PyBufferProcs {
pub bf_getbuffer: Option<crate::getbufferproc>,
pub bf_releasebuffer: Option<crate::releasebufferproc>,
}
pub type printfunc = #[repr(C)]
unsafe extern "C" fn(arg1: *mut PyObject, arg2: *mut ::libc::FILE, arg3: c_int) -> c_int; #[derive(Debug, Copy, Clone)]
pub struct PyTypeObject {
#[cfg(PyPy)]
pub ob_refcnt: Py_ssize_t,
#[cfg(PyPy)]
pub ob_pypy_link: Py_ssize_t,
#[cfg(PyPy)]
pub ob_type: *mut PyTypeObject,
#[cfg(PyPy)]
pub ob_size: Py_ssize_t,
#[cfg(not(PyPy))]
pub ob_base: object::PyVarObject,
pub tp_name: *const c_char,
pub tp_basicsize: Py_ssize_t,
pub tp_itemsize: Py_ssize_t,
pub tp_dealloc: Option<object::destructor>,
#[cfg(not(Py_3_8))]
pub tp_print: Option<printfunc>,
#[cfg(Py_3_8)]
pub tp_vectorcall_offset: Py_ssize_t,
pub tp_getattr: Option<object::getattrfunc>,
pub tp_setattr: Option<object::setattrfunc>,
pub tp_as_async: *mut PyAsyncMethods,
pub tp_repr: Option<object::reprfunc>,
pub tp_as_number: *mut PyNumberMethods,
pub tp_as_sequence: *mut PySequenceMethods,
pub tp_as_mapping: *mut PyMappingMethods,
pub tp_hash: Option<object::hashfunc>,
pub tp_call: Option<object::ternaryfunc>,
pub tp_str: Option<object::reprfunc>,
pub tp_getattro: Option<object::getattrofunc>,
pub tp_setattro: Option<object::setattrofunc>,
pub tp_as_buffer: *mut PyBufferProcs,
pub tp_flags: c_ulong,
pub tp_doc: *const c_char,
pub tp_traverse: Option<object::traverseproc>,
pub tp_clear: Option<object::inquiry>,
pub tp_richcompare: Option<object::richcmpfunc>,
pub tp_weaklistoffset: Py_ssize_t,
pub tp_iter: Option<object::getiterfunc>,
pub tp_iternext: Option<object::iternextfunc>,
pub tp_methods: *mut crate::methodobject::PyMethodDef,
pub tp_members: *mut crate::structmember::PyMemberDef,
pub tp_getset: *mut crate::descrobject::PyGetSetDef,
pub tp_base: *mut PyTypeObject,
pub tp_dict: *mut object::PyObject,
pub tp_descr_get: Option<object::descrgetfunc>,
pub tp_descr_set: Option<object::descrsetfunc>,
pub tp_dictoffset: Py_ssize_t,
pub tp_init: Option<object::initproc>,
pub tp_alloc: Option<object::allocfunc>,
pub tp_new: Option<object::newfunc>,
pub tp_free: Option<object::freefunc>,
pub tp_is_gc: Option<object::inquiry>,
pub tp_bases: *mut object::PyObject,
pub tp_mro: *mut object::PyObject,
pub tp_cache: *mut object::PyObject,
pub tp_subclasses: *mut object::PyObject,
pub tp_weaklist: *mut object::PyObject,
pub tp_del: Option<object::destructor>,
pub tp_version_tag: c_uint,
pub tp_finalize: Option<object::destructor>,
#[cfg(Py_3_8)]
pub tp_vectorcall: Option<super::vectorcallfunc>,
#[cfg(PyPy)]
pub tp_pypy_flags: std::os::raw::c_long,
#[cfg(py_sys_config = "COUNT_ALLOCS")]
pub tp_allocs: Py_ssize_t,
#[cfg(py_sys_config = "COUNT_ALLOCS")]
pub tp_frees: Py_ssize_t,
#[cfg(py_sys_config = "COUNT_ALLOCS")]
pub tp_maxalloc: Py_ssize_t,
#[cfg(py_sys_config = "COUNT_ALLOCS")]
pub tp_prev: *mut PyTypeObject,
#[cfg(py_sys_config = "COUNT_ALLOCS")]
pub tp_next: *mut PyTypeObject,
}
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy, Clone)] #[derive(Clone)]
pub struct PyTypeObject { pub struct PyHeapTypeObject {
#[cfg(PyPy)] pub ht_type: PyTypeObject,
pub ob_refcnt: Py_ssize_t, pub as_async: PyAsyncMethods,
#[cfg(PyPy)] pub as_number: PyNumberMethods,
pub ob_pypy_link: Py_ssize_t, pub as_mapping: PyMappingMethods,
#[cfg(PyPy)] pub as_sequence: PySequenceMethods,
pub ob_type: *mut PyTypeObject, pub as_buffer: PyBufferProcs,
#[cfg(PyPy)] pub ht_name: *mut object::PyObject,
pub ob_size: Py_ssize_t, pub ht_slots: *mut object::PyObject,
#[cfg(not(PyPy))] pub ht_qualname: *mut object::PyObject,
pub ob_base: object::PyVarObject, pub ht_cached_keys: *mut c_void,
pub tp_name: *const c_char, #[cfg(Py_3_9)]
pub tp_basicsize: Py_ssize_t, pub ht_module: *mut object::PyObject,
pub tp_itemsize: Py_ssize_t, }
pub tp_dealloc: Option<object::destructor>,
#[cfg(not(Py_3_8))]
pub tp_print: Option<printfunc>,
#[cfg(Py_3_8)]
pub tp_vectorcall_offset: Py_ssize_t,
pub tp_getattr: Option<object::getattrfunc>,
pub tp_setattr: Option<object::setattrfunc>,
pub tp_as_async: *mut PyAsyncMethods,
pub tp_repr: Option<object::reprfunc>,
pub tp_as_number: *mut PyNumberMethods,
pub tp_as_sequence: *mut PySequenceMethods,
pub tp_as_mapping: *mut PyMappingMethods,
pub tp_hash: Option<object::hashfunc>,
pub tp_call: Option<object::ternaryfunc>,
pub tp_str: Option<object::reprfunc>,
pub tp_getattro: Option<object::getattrofunc>,
pub tp_setattro: Option<object::setattrofunc>,
pub tp_as_buffer: *mut PyBufferProcs,
pub tp_flags: c_ulong,
pub tp_doc: *const c_char,
pub tp_traverse: Option<object::traverseproc>,
pub tp_clear: Option<object::inquiry>,
pub tp_richcompare: Option<object::richcmpfunc>,
pub tp_weaklistoffset: Py_ssize_t,
pub tp_iter: Option<object::getiterfunc>,
pub tp_iternext: Option<object::iternextfunc>,
pub tp_methods: *mut crate::methodobject::PyMethodDef,
pub tp_members: *mut crate::structmember::PyMemberDef,
pub tp_getset: *mut crate::descrobject::PyGetSetDef,
pub tp_base: *mut PyTypeObject,
pub tp_dict: *mut object::PyObject,
pub tp_descr_get: Option<object::descrgetfunc>,
pub tp_descr_set: Option<object::descrsetfunc>,
pub tp_dictoffset: Py_ssize_t,
pub tp_init: Option<object::initproc>,
pub tp_alloc: Option<object::allocfunc>,
pub tp_new: Option<object::newfunc>,
pub tp_free: Option<object::freefunc>,
pub tp_is_gc: Option<object::inquiry>,
pub tp_bases: *mut object::PyObject,
pub tp_mro: *mut object::PyObject,
pub tp_cache: *mut object::PyObject,
pub tp_subclasses: *mut object::PyObject,
pub tp_weaklist: *mut object::PyObject,
pub tp_del: Option<object::destructor>,
pub tp_version_tag: c_uint,
pub tp_finalize: Option<object::destructor>,
#[cfg(Py_3_8)]
pub tp_vectorcall: Option<super::vectorcallfunc>,
#[cfg(PyPy)]
pub tp_pypy_flags: std::os::raw::c_long,
#[cfg(py_sys_config = "COUNT_ALLOCS")]
pub tp_allocs: Py_ssize_t,
#[cfg(py_sys_config = "COUNT_ALLOCS")]
pub tp_frees: Py_ssize_t,
#[cfg(py_sys_config = "COUNT_ALLOCS")]
pub tp_maxalloc: Py_ssize_t,
#[cfg(py_sys_config = "COUNT_ALLOCS")]
pub tp_prev: *mut PyTypeObject,
#[cfg(py_sys_config = "COUNT_ALLOCS")]
pub tp_next: *mut PyTypeObject,
}
#[repr(C)]
#[derive(Clone)]
pub struct PyHeapTypeObject {
pub ht_type: PyTypeObject,
pub as_async: PyAsyncMethods,
pub as_number: PyNumberMethods,
pub as_mapping: PyMappingMethods,
pub as_sequence: PySequenceMethods,
pub as_buffer: PyBufferProcs,
pub ht_name: *mut object::PyObject,
pub ht_slots: *mut object::PyObject,
pub ht_qualname: *mut object::PyObject,
pub ht_cached_keys: *mut c_void,
}
impl Default for PyHeapTypeObject {
#[inline]
fn default() -> Self {
unsafe { mem::zeroed() }
}
}
impl Default for PyHeapTypeObject {
#[inline] #[inline]
pub unsafe fn PyHeapType_GET_MEMBERS( fn default() -> Self {
etype: *mut PyHeapTypeObject, unsafe { mem::zeroed() }
) -> *mut crate::structmember::PyMemberDef {
let py_type = object::Py_TYPE(etype as *mut object::PyObject);
let ptr = etype.offset((*py_type).tp_basicsize);
ptr as *mut crate::structmember::PyMemberDef
} }
} }
// The exported types depend on whether Py_LIMITED_API is set #[inline]
pub use self::typeobject::*; pub unsafe fn PyHeapType_GET_MEMBERS(
etype: *mut PyHeapTypeObject,
) -> *mut crate::structmember::PyMemberDef {
let py_type = object::Py_TYPE(etype as *mut object::PyObject);
let ptr = etype.offset((*py_type).tp_basicsize);
ptr as *mut crate::structmember::PyMemberDef
}
// skipped _PyType_Name // skipped _PyType_Name
// skipped _PyType_Lookup // skipped _PyType_Lookup

View File

@ -0,0 +1,111 @@
use crate::{PyObject, Py_ssize_t};
#[repr(C)]
#[derive(Debug)]
pub struct PyBaseExceptionObject {
pub ob_base: PyObject,
pub dict: *mut PyObject,
pub args: *mut PyObject,
pub traceback: *mut PyObject,
pub context: *mut PyObject,
pub cause: *mut PyObject,
pub suppress_context: char,
}
#[repr(C)]
#[derive(Debug)]
pub struct PySyntaxErrorObject {
pub exception_base: PyBaseExceptionObject,
pub msg: *mut PyObject,
pub filename: *mut PyObject,
pub lineno: *mut PyObject,
pub offset: *mut PyObject,
#[cfg(Py_3_10)]
pub end_lineno: *mut PyObject,
#[cfg(Py_3_10)]
pub end_offset: *mut PyObject,
pub text: *mut PyObject,
pub print_file_and_line: *mut PyObject,
}
#[repr(C)]
#[derive(Debug)]
pub struct PyImportErrorObject {
pub exception_base: PyBaseExceptionObject,
pub msg: *mut PyObject,
pub name: *mut PyObject,
pub path: *mut PyObject,
}
#[repr(C)]
#[derive(Debug)]
pub struct PyUnicodeErrorObject {
pub exception_base: PyBaseExceptionObject,
pub encoding: *mut PyObject,
pub object: *mut PyObject,
pub start: Py_ssize_t,
pub end: Py_ssize_t,
pub reason: *mut PyObject,
}
#[repr(C)]
#[derive(Debug)]
pub struct PySystemExitObject {
pub exception_base: PyBaseExceptionObject,
pub code: *mut PyObject,
}
#[repr(C)]
#[derive(Debug)]
pub struct PyOSErrorObject {
pub exception_base: PyBaseExceptionObject,
pub myerrno: *mut PyObject,
pub strerror: *mut PyObject,
pub filename: *mut PyObject,
pub filename2: *mut PyObject,
#[cfg(windows)]
pub winerror: *mut PyObject,
pub written: Py_ssize_t,
}
#[repr(C)]
#[derive(Debug)]
pub struct PyStopIterationObject {
pub exception_base: PyBaseExceptionObject,
pub value: *mut PyObject,
}
// skipped PyNameErrorObject
// skipped PyAttributeErrorObject
// skipped PyEnvironmentErrorObject
// skipped PyWindowsErrorObject
// skipped _PyErr_SetKeyError
// skipped _PyErr_GetTopmostException
// skipped _PyErr_GetExcInfo
// skipped _PyErr_ChainExceptions
// skipped PyErr_SetFromErrnoWithUnicodeFilename
// skipped _PyErr_FormatFromCause
// skipped PyErr_SetFromWindowsErrWithUnicodeFilename
// skipped PyErr_SetExcFromWindowsErrWithUnicodeFilename
// skipped _PyErr_TrySetFromCause
// skipped PySignal_SetWakeupFd
// skipped _PyErr_CheckSignals
// skipped PyErr_SyntaxLocationObject
// skipped PyErr_RangedSyntaxLocationObject
// skipped PyErr_ProgramTextObject
// skipped _PyErr_ProgramDecodedTextObject
// skipped _PyUnicodeTranslateError_Create
// skipped _PyErr_WriteUnraisableMsg
// skipped _Py_FatalErrorFunc
// skipped _Py_FatalErrorFormat
// skipped Py_FatalError

View File

@ -26,7 +26,16 @@ pub const PyTrace_OPCODE: c_int = 7;
// skipped PyTraceInfo // skipped PyTraceInfo
// skipped CFrame // skipped CFrame
// skipped _PyErr_StackItem
#[repr(C)]
#[derive(Clone, Copy)]
pub struct _PyErr_StackItem {
pub exc_type: *mut PyObject,
pub exc_value: *mut PyObject,
pub exc_traceback: *mut PyObject,
pub previous_item: *mut _PyErr_StackItem,
}
// skipped _PyStackChunk // skipped _PyStackChunk
// skipped _ts (aka PyThreadState) // skipped _ts (aka PyThreadState)

View File

@ -301,8 +301,6 @@ pub use self::fileutils::*;
pub use self::floatobject::*; pub use self::floatobject::*;
#[cfg(not(Py_LIMITED_API))] #[cfg(not(Py_LIMITED_API))]
pub use self::funcobject::*; pub use self::funcobject::*;
#[cfg(not(Py_LIMITED_API))]
pub use self::genobject::*;
pub use self::import::*; pub use self::import::*;
pub use self::intrcheck::*; pub use self::intrcheck::*;
pub use self::iterobject::*; pub use self::iterobject::*;
@ -373,8 +371,6 @@ mod floatobject;
#[cfg(not(Py_LIMITED_API))] #[cfg(not(Py_LIMITED_API))]
pub(crate) mod funcobject; pub(crate) mod funcobject;
// skipped genericaliasobject.h // skipped genericaliasobject.h
#[cfg(not(Py_LIMITED_API))]
mod genobject;
mod import; mod import;
// skipped interpreteridobject.h // skipped interpreteridobject.h
mod intrcheck; mod intrcheck;

View File

@ -2,77 +2,6 @@ use crate::object::*;
use crate::pyport::Py_ssize_t; use crate::pyport::Py_ssize_t;
use std::os::raw::{c_char, c_int}; use std::os::raw::{c_char, c_int};
#[repr(C)]
#[derive(Debug)]
pub struct PyBaseExceptionObject {
pub ob_base: PyObject,
pub dict: *mut PyObject,
pub args: *mut PyObject,
pub traceback: *mut PyObject,
pub context: *mut PyObject,
pub cause: *mut PyObject,
pub suppress_context: char,
}
#[repr(C)]
#[derive(Debug)]
pub struct PySyntaxErrorObject {
pub exception_base: PyBaseExceptionObject,
pub msg: *mut PyObject,
pub filename: *mut PyObject,
pub lineno: *mut PyObject,
pub offset: *mut PyObject,
pub text: *mut PyObject,
pub print_file_and_line: *mut PyObject,
}
#[repr(C)]
#[derive(Debug)]
pub struct PyImportErrorObject {
pub exception_base: PyBaseExceptionObject,
pub msg: *mut PyObject,
pub name: *mut PyObject,
pub path: *mut PyObject,
}
#[repr(C)]
#[derive(Debug)]
pub struct PyUnicodeErrorObject {
pub exception_base: PyBaseExceptionObject,
pub encoding: *mut PyObject,
pub object: *mut PyObject,
pub start: Py_ssize_t,
pub end: Py_ssize_t,
pub reason: *mut PyObject,
}
#[repr(C)]
#[derive(Debug)]
pub struct PySystemExitObject {
pub exception_base: PyBaseExceptionObject,
pub code: *mut PyObject,
}
#[repr(C)]
#[derive(Debug)]
pub struct PyOSErrorObject {
pub exception_base: PyBaseExceptionObject,
pub myerrno: *mut PyObject,
pub strerror: *mut PyObject,
pub filename: *mut PyObject,
pub filename2: *mut PyObject,
#[cfg(windows)]
pub winerror: *mut PyObject,
pub written: Py_ssize_t,
}
#[repr(C)]
#[derive(Debug)]
pub struct PyStopIterationObject {
pub exception_base: PyBaseExceptionObject,
pub value: *mut PyObject,
}
extern "C" { extern "C" {
#[cfg_attr(PyPy, link_name = "PyPyErr_SetNone")] #[cfg_attr(PyPy, link_name = "PyPyErr_SetNone")]
pub fn PyErr_SetNone(arg1: *mut PyObject); pub fn PyErr_SetNone(arg1: *mut PyObject);

View File

@ -24,16 +24,6 @@ pub const PYOS_STACK_MARGIN: c_int = 2048;
// skipped PyOS_CheckStack under Microsoft C // skipped PyOS_CheckStack under Microsoft C
#[repr(C)]
#[derive(Copy, Clone)]
#[cfg(not(Py_LIMITED_API))]
pub struct PyCompilerFlags {
pub cf_flags: c_int,
}
#[cfg(Py_LIMITED_API)]
opaque_struct!(PyCompilerFlags);
#[cfg(all(not(Py_LIMITED_API), not(Py_3_10)))] #[cfg(all(not(Py_LIMITED_API), not(Py_3_10)))]
opaque_struct!(_mod); opaque_struct!(_mod);