diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0e2cbfa6..c0a87760 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -111,7 +111,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [2.7.17, 2.7.18, 3.5.4, 3.5.9, 3.5.10, 3.6.7, 3.6.8, 3.6.9, 3.6.10, 3.6.11, 3.6.12, 3.6.13, 3.6.14, 3.6.15, 3.7.1, 3.7.5, 3.7.6, 3.7.7, 3.7.8, 3.7.9, 3.7.10, 3.7.11, 3.7.12, 3.8.0, 3.8.1, 3.8.2, 3.8.3, 3.8.4, 3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9, 3.8.10, 3.8.11, 3.8.12, 3.9.0, 3.9.1, 3.9.2, 3.9.3, 3.9.4, 3.9.5, 3.9.6, 3.9.7] + python-version: [2.7.17, 2.7.18, 3.5.4, 3.5.9, 3.5.10, 3.6.7, 3.6.8, 3.6.9, 3.6.10, 3.6.11, 3.6.12, 3.6.13, 3.6.14, 3.6.15, 3.7.1, 3.7.5, 3.7.6, 3.7.7, 3.7.8, 3.7.9, 3.7.10, 3.7.11, 3.7.12, 3.8.0, 3.8.1, 3.8.2, 3.8.3, 3.8.4, 3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9, 3.8.10, 3.8.11, 3.8.12, 3.9.0, 3.9.1, 3.9.2, 3.9.3, 3.9.4, 3.9.5, 3.9.6, 3.9.7, 3.10.0-rc.2] # TODO: also test windows os: [ubuntu-latest, macos-latest] steps: diff --git a/ci/update_python_test_versions.py b/ci/update_python_test_versions.py index 78aca1c6..4ac7e9d2 100644 --- a/ci/update_python_test_versions.py +++ b/ci/update_python_test_versions.py @@ -15,7 +15,7 @@ def get_github_python_versions(): raw_versions = [v["version"] for v in versions_json] versions = [] for version_str in raw_versions: - if "-" in version_str: + if "-" in version_str and version_str != "3.10.0-rc.2": continue major, minor, patch = parse_version(version_str) diff --git a/src/python_bindings/mod.rs b/src/python_bindings/mod.rs index b67d4f37..5742731c 100644 --- a/src/python_bindings/mod.rs +++ b/src/python_bindings/mod.rs @@ -5,6 +5,7 @@ pub mod v3_6_6; pub mod v3_7_0; pub mod v3_8_0; pub mod v3_9_5; +pub mod v3_10_0; // currently the PyRuntime struct used from Python 3.7 on really can't be // exposed in a cross platform way using bindgen. PyRuntime has several mutex's @@ -28,7 +29,7 @@ pub mod pyruntime { _ => 24 } }, - Version{major: 3, minor: 8..=9, ..} => 24, + Version{major: 3, minor: 8..=10, ..} => 24, _ => 16 } } @@ -50,7 +51,7 @@ pub mod pyruntime { _ => 32 } }, - Version{major: 3, minor: 8..=9, ..} => 32, + Version{major: 3, minor: 8..=10, ..} => 32, _ => 24 } } @@ -72,7 +73,7 @@ pub mod pyruntime { } }, Version{major: 3, minor: 8, ..} => { Some(1416) }, - Version{major: 3, minor: 9, ..} => { Some(616) }, + Version{major: 3, minor: 9..=10, ..} => { Some(616) }, _ => None } } @@ -90,7 +91,7 @@ pub mod pyruntime { } }, Version{major: 3, minor: 8, ..} => Some(788), - Version{major: 3, minor: 9, ..} => Some(352), + Version{major: 3, minor: 9..=10, ..} => Some(352), _ => None } } @@ -100,7 +101,7 @@ pub mod pyruntime { match version { Version{major: 3, minor: 7, ..} => Some(828), Version{major: 3, minor: 8, ..} => Some(804), - Version{major: 3, minor: 9, ..} => Some(364), + Version{major: 3, minor: 9..=10, ..} => Some(364), _ => None } } @@ -111,7 +112,7 @@ pub mod pyruntime { Version{major: 3, minor: 7, patch: 0..=3, ..} => Some(1408), Version{major: 3, minor: 7, ..} => Some(1496), Version{major: 3, minor: 8, ..} => Some(1384), - Version{major: 3, minor: 9, ..} => Some(584), + Version{major: 3, minor: 9..=10, ..} => Some(584), _ => None } } @@ -130,7 +131,7 @@ pub mod pyruntime { } }, Version{major: 3, minor: 8, ..} => Some(1368), - Version{major: 3, minor: 9, ..} => Some(568), + Version{major: 3, minor: 9..=10, ..} => Some(568), _ => None } } @@ -153,7 +154,7 @@ pub mod pyruntime { } }, Version{major: 3, minor: 8, ..} => Some(1296), - Version{major: 3, minor: 9, ..} => Some(496), + Version{major: 3, minor: 9..=10, ..} => Some(496), _ => None } } @@ -172,7 +173,7 @@ pub mod pyruntime { } }, Version{major: 3, minor: 8, ..} => Some(1224), - Version{major: 3, minor: 9, ..} => Some(424), + Version{major: 3, minor: 9..=10, ..} => Some(424), _ => None } } diff --git a/src/python_bindings/v3_10_0.rs b/src/python_bindings/v3_10_0.rs new file mode 100644 index 00000000..74da9649 --- /dev/null +++ b/src/python_bindings/v3_10_0.rs @@ -0,0 +1,1963 @@ +// Generated bindings for python v3.10.0rc1 +#![allow(dead_code)] +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(clippy::useless_transmute)] +#![allow(clippy::default_trait_access)] +#![allow(clippy::cast_lossless)] +#![allow(clippy::trivially_copy_pass_by_ref)] + +/* automatically generated by rust-bindgen */ + +#[repr(C)] +#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub struct __BindgenBitfieldUnit +where + Storage: AsRef<[u8]> + AsMut<[u8]>, +{ + storage: Storage, + align: [Align; 0], +} +impl __BindgenBitfieldUnit +where + Storage: AsRef<[u8]> + AsMut<[u8]>, +{ + #[inline] + pub fn new(storage: Storage) -> Self { + Self { storage, align: [] } + } + #[inline] + pub fn get_bit(&self, index: usize) -> bool { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = self.storage.as_ref()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + byte & mask == mask + } + #[inline] + pub fn set_bit(&mut self, index: usize, val: bool) { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = &mut self.storage.as_mut()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + if val { + *byte |= mask; + } else { + *byte &= !mask; + } + } + #[inline] + pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + let mut val = 0; + for i in 0..(bit_width as usize) { + if self.get_bit(i + bit_offset) { + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + val |= 1 << index; + } + } + val + } + #[inline] + pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + for i in 0..(bit_width as usize) { + let mask = 1 << i; + let val_bit_is_set = val & mask == mask; + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + self.set_bit(index + bit_offset, val_bit_is_set); + } + } +} +#[repr(C)] +#[derive(Default)] +pub struct __IncompleteArrayField(::std::marker::PhantomData, [T; 0]); +impl __IncompleteArrayField { + #[inline] + pub fn new() -> Self { + __IncompleteArrayField(::std::marker::PhantomData, []) + } + #[inline] + pub unsafe fn as_ptr(&self) -> *const T { + ::std::mem::transmute(self) + } + #[inline] + pub unsafe fn as_mut_ptr(&mut self) -> *mut T { + ::std::mem::transmute(self) + } + #[inline] + pub unsafe fn as_slice(&self, len: usize) -> &[T] { + ::std::slice::from_raw_parts(self.as_ptr(), len) + } + #[inline] + pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + } +} +impl ::std::fmt::Debug for __IncompleteArrayField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + fmt.write_str("__IncompleteArrayField") + } +} +impl ::std::clone::Clone for __IncompleteArrayField { + #[inline] + fn clone(&self) -> Self { + Self::new() + } +} +pub type __uint8_t = ::std::os::raw::c_uchar; +pub type __uint16_t = ::std::os::raw::c_ushort; +pub type __uint32_t = ::std::os::raw::c_uint; +pub type __int64_t = ::std::os::raw::c_long; +pub type __uint64_t = ::std::os::raw::c_ulong; +pub type __ssize_t = ::std::os::raw::c_long; +pub type wchar_t = ::std::os::raw::c_int; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +impl Default for __pthread_internal_list { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type __pthread_list_t = __pthread_internal_list; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __pthread_mutex_s { + pub __lock: ::std::os::raw::c_int, + pub __count: ::std::os::raw::c_uint, + pub __owner: ::std::os::raw::c_int, + pub __nusers: ::std::os::raw::c_uint, + pub __kind: ::std::os::raw::c_int, + pub __spins: ::std::os::raw::c_short, + pub __elision: ::std::os::raw::c_short, + pub __list: __pthread_list_t, +} +impl Default for __pthread_mutex_s { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct __pthread_cond_s { + pub __bindgen_anon_1: __pthread_cond_s__bindgen_ty_1, + pub __bindgen_anon_2: __pthread_cond_s__bindgen_ty_2, + pub __g_refs: [::std::os::raw::c_uint; 2usize], + pub __g_size: [::std::os::raw::c_uint; 2usize], + pub __g1_orig_size: ::std::os::raw::c_uint, + pub __wrefs: ::std::os::raw::c_uint, + pub __g_signals: [::std::os::raw::c_uint; 2usize], +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union __pthread_cond_s__bindgen_ty_1 { + pub __wseq: ::std::os::raw::c_ulonglong, + pub __wseq32: __pthread_cond_s__bindgen_ty_1__bindgen_ty_1, + _bindgen_union_align: u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct __pthread_cond_s__bindgen_ty_1__bindgen_ty_1 { + pub __low: ::std::os::raw::c_uint, + pub __high: ::std::os::raw::c_uint, +} +impl Default for __pthread_cond_s__bindgen_ty_1 { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union __pthread_cond_s__bindgen_ty_2 { + pub __g1_start: ::std::os::raw::c_ulonglong, + pub __g1_start32: __pthread_cond_s__bindgen_ty_2__bindgen_ty_1, + _bindgen_union_align: u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct __pthread_cond_s__bindgen_ty_2__bindgen_ty_1 { + pub __low: ::std::os::raw::c_uint, + pub __high: ::std::os::raw::c_uint, +} +impl Default for __pthread_cond_s__bindgen_ty_2 { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +impl Default for __pthread_cond_s { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type pthread_key_t = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Copy, Clone)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [::std::os::raw::c_char; 40usize], + pub __align: ::std::os::raw::c_long, + _bindgen_union_align: [u64; 5usize], +} +impl Default for pthread_mutex_t { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union pthread_cond_t { + pub __data: __pthread_cond_s, + pub __size: [::std::os::raw::c_char; 48usize], + pub __align: ::std::os::raw::c_longlong, + _bindgen_union_align: [u64; 6usize], +} +impl Default for pthread_cond_t { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type Py_ssize_t = isize; +pub type Py_hash_t = Py_ssize_t; +pub type PyTypeObject = _typeobject; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _object { + pub ob_refcnt: Py_ssize_t, + pub ob_type: *mut PyTypeObject, +} +impl Default for _object { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type PyObject = _object; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PyVarObject { + pub ob_base: PyObject, + pub ob_size: Py_ssize_t, +} +impl Default for PyVarObject { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type unaryfunc = + ::std::option::Option *mut PyObject>; +pub type binaryfunc = ::std::option::Option< + unsafe extern "C" fn(arg1: *mut PyObject, arg2: *mut PyObject) -> *mut PyObject, +>; +pub type ternaryfunc = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut PyObject, + arg2: *mut PyObject, + arg3: *mut PyObject, + ) -> *mut PyObject, +>; +pub type inquiry = + ::std::option::Option ::std::os::raw::c_int>; +pub type lenfunc = ::std::option::Option Py_ssize_t>; +pub type ssizeargfunc = ::std::option::Option< + unsafe extern "C" fn(arg1: *mut PyObject, arg2: Py_ssize_t) -> *mut PyObject, +>; +pub type ssizeobjargproc = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut PyObject, + arg2: Py_ssize_t, + arg3: *mut PyObject, + ) -> ::std::os::raw::c_int, +>; +pub type objobjargproc = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut PyObject, + arg2: *mut PyObject, + arg3: *mut PyObject, + ) -> ::std::os::raw::c_int, +>; +pub type objobjproc = ::std::option::Option< + unsafe extern "C" fn(arg1: *mut PyObject, arg2: *mut PyObject) -> ::std::os::raw::c_int, +>; +pub type visitproc = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut PyObject, + arg2: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, +>; +pub type traverseproc = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut PyObject, + arg2: visitproc, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, +>; +pub type freefunc = ::std::option::Option; +pub type destructor = ::std::option::Option; +pub type getattrfunc = ::std::option::Option< + unsafe extern "C" fn(arg1: *mut PyObject, arg2: *mut ::std::os::raw::c_char) -> *mut PyObject, +>; +pub type getattrofunc = ::std::option::Option< + unsafe extern "C" fn(arg1: *mut PyObject, arg2: *mut PyObject) -> *mut PyObject, +>; +pub type setattrfunc = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut PyObject, + arg2: *mut ::std::os::raw::c_char, + arg3: *mut PyObject, + ) -> ::std::os::raw::c_int, +>; +pub type setattrofunc = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut PyObject, + arg2: *mut PyObject, + arg3: *mut PyObject, + ) -> ::std::os::raw::c_int, +>; +pub type reprfunc = + ::std::option::Option *mut PyObject>; +pub type hashfunc = ::std::option::Option Py_hash_t>; +pub type richcmpfunc = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut PyObject, + arg2: *mut PyObject, + arg3: ::std::os::raw::c_int, + ) -> *mut PyObject, +>; +pub type getiterfunc = + ::std::option::Option *mut PyObject>; +pub type iternextfunc = + ::std::option::Option *mut PyObject>; +pub type descrgetfunc = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut PyObject, + arg2: *mut PyObject, + arg3: *mut PyObject, + ) -> *mut PyObject, +>; +pub type descrsetfunc = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut PyObject, + arg2: *mut PyObject, + arg3: *mut PyObject, + ) -> ::std::os::raw::c_int, +>; +pub type initproc = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut PyObject, + arg2: *mut PyObject, + arg3: *mut PyObject, + ) -> ::std::os::raw::c_int, +>; +pub type newfunc = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut PyTypeObject, + arg2: *mut PyObject, + arg3: *mut PyObject, + ) -> *mut PyObject, +>; +pub type allocfunc = ::std::option::Option< + unsafe extern "C" fn(arg1: *mut PyTypeObject, arg2: Py_ssize_t) -> *mut PyObject, +>; +pub const PySendResult_PYGEN_RETURN: PySendResult = 0; +pub const PySendResult_PYGEN_ERROR: PySendResult = -1; +pub const PySendResult_PYGEN_NEXT: PySendResult = 1; +pub type PySendResult = i32; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bufferinfo { + pub buf: *mut ::std::os::raw::c_void, + pub obj: *mut PyObject, + pub len: Py_ssize_t, + pub itemsize: Py_ssize_t, + pub readonly: ::std::os::raw::c_int, + pub ndim: ::std::os::raw::c_int, + pub format: *mut ::std::os::raw::c_char, + pub shape: *mut Py_ssize_t, + pub strides: *mut Py_ssize_t, + pub suboffsets: *mut Py_ssize_t, + pub internal: *mut ::std::os::raw::c_void, +} +impl Default for bufferinfo { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type Py_buffer = bufferinfo; +pub type getbufferproc = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut PyObject, + arg2: *mut Py_buffer, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, +>; +pub type releasebufferproc = + ::std::option::Option; +pub type vectorcallfunc = ::std::option::Option< + unsafe extern "C" fn( + callable: *mut PyObject, + args: *const *mut PyObject, + nargsf: usize, + kwnames: *mut PyObject, + ) -> *mut PyObject, +>; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PyNumberMethods { + pub nb_add: binaryfunc, + pub nb_subtract: binaryfunc, + pub nb_multiply: binaryfunc, + pub nb_remainder: binaryfunc, + pub nb_divmod: binaryfunc, + pub nb_power: ternaryfunc, + pub nb_negative: unaryfunc, + pub nb_positive: unaryfunc, + pub nb_absolute: unaryfunc, + pub nb_bool: inquiry, + pub nb_invert: unaryfunc, + pub nb_lshift: binaryfunc, + pub nb_rshift: binaryfunc, + pub nb_and: binaryfunc, + pub nb_xor: binaryfunc, + pub nb_or: binaryfunc, + pub nb_int: unaryfunc, + pub nb_reserved: *mut ::std::os::raw::c_void, + pub nb_float: unaryfunc, + pub nb_inplace_add: binaryfunc, + pub nb_inplace_subtract: binaryfunc, + pub nb_inplace_multiply: binaryfunc, + pub nb_inplace_remainder: binaryfunc, + pub nb_inplace_power: ternaryfunc, + pub nb_inplace_lshift: binaryfunc, + pub nb_inplace_rshift: binaryfunc, + pub nb_inplace_and: binaryfunc, + pub nb_inplace_xor: binaryfunc, + pub nb_inplace_or: binaryfunc, + pub nb_floor_divide: binaryfunc, + pub nb_true_divide: binaryfunc, + pub nb_inplace_floor_divide: binaryfunc, + pub nb_inplace_true_divide: binaryfunc, + pub nb_index: unaryfunc, + pub nb_matrix_multiply: binaryfunc, + pub nb_inplace_matrix_multiply: binaryfunc, +} +impl Default for PyNumberMethods { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PySequenceMethods { + pub sq_length: lenfunc, + pub sq_concat: binaryfunc, + pub sq_repeat: ssizeargfunc, + pub sq_item: ssizeargfunc, + pub was_sq_slice: *mut ::std::os::raw::c_void, + pub sq_ass_item: ssizeobjargproc, + pub was_sq_ass_slice: *mut ::std::os::raw::c_void, + pub sq_contains: objobjproc, + pub sq_inplace_concat: binaryfunc, + pub sq_inplace_repeat: ssizeargfunc, +} +impl Default for PySequenceMethods { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PyMappingMethods { + pub mp_length: lenfunc, + pub mp_subscript: binaryfunc, + pub mp_ass_subscript: objobjargproc, +} +impl Default for PyMappingMethods { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type sendfunc = ::std::option::Option< + unsafe extern "C" fn( + iter: *mut PyObject, + value: *mut PyObject, + result: *mut *mut PyObject, + ) -> PySendResult, +>; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PyAsyncMethods { + pub am_await: unaryfunc, + pub am_aiter: unaryfunc, + pub am_anext: unaryfunc, + pub am_send: sendfunc, +} +impl Default for PyAsyncMethods { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PyBufferProcs { + pub bf_getbuffer: getbufferproc, + pub bf_releasebuffer: releasebufferproc, +} +impl Default for PyBufferProcs { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _typeobject { + pub ob_base: PyVarObject, + pub tp_name: *const ::std::os::raw::c_char, + pub tp_basicsize: Py_ssize_t, + pub tp_itemsize: Py_ssize_t, + pub tp_dealloc: destructor, + pub tp_vectorcall_offset: Py_ssize_t, + pub tp_getattr: getattrfunc, + pub tp_setattr: setattrfunc, + pub tp_as_async: *mut PyAsyncMethods, + pub tp_repr: reprfunc, + pub tp_as_number: *mut PyNumberMethods, + pub tp_as_sequence: *mut PySequenceMethods, + pub tp_as_mapping: *mut PyMappingMethods, + pub tp_hash: hashfunc, + pub tp_call: ternaryfunc, + pub tp_str: reprfunc, + pub tp_getattro: getattrofunc, + pub tp_setattro: setattrofunc, + pub tp_as_buffer: *mut PyBufferProcs, + pub tp_flags: ::std::os::raw::c_ulong, + pub tp_doc: *const ::std::os::raw::c_char, + pub tp_traverse: traverseproc, + pub tp_clear: inquiry, + pub tp_richcompare: richcmpfunc, + pub tp_weaklistoffset: Py_ssize_t, + pub tp_iter: getiterfunc, + pub tp_iternext: iternextfunc, + pub tp_methods: *mut PyMethodDef, + pub tp_members: *mut PyMemberDef, + pub tp_getset: *mut PyGetSetDef, + pub tp_base: *mut _typeobject, + pub tp_dict: *mut PyObject, + pub tp_descr_get: descrgetfunc, + pub tp_descr_set: descrsetfunc, + pub tp_dictoffset: Py_ssize_t, + pub tp_init: initproc, + pub tp_alloc: allocfunc, + pub tp_new: newfunc, + pub tp_free: freefunc, + pub tp_is_gc: inquiry, + pub tp_bases: *mut PyObject, + pub tp_mro: *mut PyObject, + pub tp_cache: *mut PyObject, + pub tp_subclasses: *mut PyObject, + pub tp_weaklist: *mut PyObject, + pub tp_del: destructor, + pub tp_version_tag: ::std::os::raw::c_uint, + pub tp_finalize: destructor, + pub tp_vectorcall: vectorcallfunc, +} +impl Default for _typeobject { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PyBytesObject { + pub ob_base: PyVarObject, + pub ob_shash: Py_hash_t, + pub ob_sval: [::std::os::raw::c_char; 1usize], +} +impl Default for PyBytesObject { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type Py_UCS4 = u32; +pub type Py_UCS2 = u16; +pub type Py_UCS1 = u8; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PyASCIIObject { + pub ob_base: PyObject, + pub length: Py_ssize_t, + pub hash: Py_hash_t, + pub state: PyASCIIObject__bindgen_ty_1, + pub wstr: *mut wchar_t, +} +#[repr(C)] +#[repr(align(4))] +#[derive(Debug, Default, Copy, Clone)] +pub struct PyASCIIObject__bindgen_ty_1 { + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize], u8>, +} +impl PyASCIIObject__bindgen_ty_1 { + #[inline] + pub fn interned(&self) -> ::std::os::raw::c_uint { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u32) } + } + #[inline] + pub fn set_interned(&mut self, val: ::std::os::raw::c_uint) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn kind(&self) -> ::std::os::raw::c_uint { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 3u8) as u32) } + } + #[inline] + pub fn set_kind(&mut self, val: ::std::os::raw::c_uint) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 3u8, val as u64) + } + } + #[inline] + pub fn compact(&self) -> ::std::os::raw::c_uint { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u32) } + } + #[inline] + pub fn set_compact(&mut self, val: ::std::os::raw::c_uint) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn ascii(&self) -> ::std::os::raw::c_uint { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u32) } + } + #[inline] + pub fn set_ascii(&mut self, val: ::std::os::raw::c_uint) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn ready(&self) -> ::std::os::raw::c_uint { + unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u32) } + } + #[inline] + pub fn set_ready(&mut self, val: ::std::os::raw::c_uint) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(7usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + interned: ::std::os::raw::c_uint, + kind: ::std::os::raw::c_uint, + compact: ::std::os::raw::c_uint, + ascii: ::std::os::raw::c_uint, + ready: ::std::os::raw::c_uint, + ) -> __BindgenBitfieldUnit<[u8; 4usize], u8> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize], u8> = + Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let interned: u32 = unsafe { ::std::mem::transmute(interned) }; + interned as u64 + }); + __bindgen_bitfield_unit.set(2usize, 3u8, { + let kind: u32 = unsafe { ::std::mem::transmute(kind) }; + kind as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let compact: u32 = unsafe { ::std::mem::transmute(compact) }; + compact as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let ascii: u32 = unsafe { ::std::mem::transmute(ascii) }; + ascii as u64 + }); + __bindgen_bitfield_unit.set(7usize, 1u8, { + let ready: u32 = unsafe { ::std::mem::transmute(ready) }; + ready as u64 + }); + __bindgen_bitfield_unit + } +} +impl Default for PyASCIIObject { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PyCompactUnicodeObject { + pub _base: PyASCIIObject, + pub utf8_length: Py_ssize_t, + pub utf8: *mut ::std::os::raw::c_char, + pub wstr_length: Py_ssize_t, +} +impl Default for PyCompactUnicodeObject { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct PyUnicodeObject { + pub _base: PyCompactUnicodeObject, + pub data: PyUnicodeObject__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union PyUnicodeObject__bindgen_ty_1 { + pub any: *mut ::std::os::raw::c_void, + pub latin1: *mut Py_UCS1, + pub ucs2: *mut Py_UCS2, + pub ucs4: *mut Py_UCS4, + _bindgen_union_align: u64, +} +impl Default for PyUnicodeObject__bindgen_ty_1 { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +impl Default for PyUnicodeObject { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type PyLongObject = _longobject; +pub type digit = u32; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _longobject { + pub ob_base: PyVarObject, + pub ob_digit: [digit; 1usize], +} +impl Default for _longobject { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PyFloatObject { + pub ob_base: PyObject, + pub ob_fval: f64, +} +impl Default for PyFloatObject { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PyTupleObject { + pub ob_base: PyVarObject, + pub ob_item: [*mut PyObject; 1usize], +} +impl Default for PyTupleObject { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PyListObject { + pub ob_base: PyVarObject, + pub ob_item: *mut *mut PyObject, + pub allocated: Py_ssize_t, +} +impl Default for PyListObject { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type PyDictKeysObject = _dictkeysobject; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PyDictObject { + pub ob_base: PyObject, + pub ma_used: Py_ssize_t, + pub ma_version_tag: u64, + pub ma_keys: *mut PyDictKeysObject, + pub ma_values: *mut *mut PyObject, +} +impl Default for PyDictObject { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type PyCFunction = ::std::option::Option< + unsafe extern "C" fn(arg1: *mut PyObject, arg2: *mut PyObject) -> *mut PyObject, +>; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PyMethodDef { + pub ml_name: *const ::std::os::raw::c_char, + pub ml_meth: PyCFunction, + pub ml_flags: ::std::os::raw::c_int, + pub ml_doc: *const ::std::os::raw::c_char, +} +impl Default for PyMethodDef { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type Py_OpenCodeHookFunction = ::std::option::Option< + unsafe extern "C" fn(arg1: *mut PyObject, arg2: *mut ::std::os::raw::c_void) -> *mut PyObject, +>; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _PyOpcache { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PyCodeObject { + pub ob_base: PyObject, + pub co_argcount: ::std::os::raw::c_int, + pub co_posonlyargcount: ::std::os::raw::c_int, + pub co_kwonlyargcount: ::std::os::raw::c_int, + pub co_nlocals: ::std::os::raw::c_int, + pub co_stacksize: ::std::os::raw::c_int, + pub co_flags: ::std::os::raw::c_int, + pub co_firstlineno: ::std::os::raw::c_int, + pub co_code: *mut PyObject, + pub co_consts: *mut PyObject, + pub co_names: *mut PyObject, + pub co_varnames: *mut PyObject, + pub co_freevars: *mut PyObject, + pub co_cellvars: *mut PyObject, + pub co_cell2arg: *mut Py_ssize_t, + pub co_filename: *mut PyObject, + pub co_name: *mut PyObject, + pub co_linetable: *mut PyObject, + pub co_zombieframe: *mut ::std::os::raw::c_void, + pub co_weakreflist: *mut PyObject, + pub co_extra: *mut ::std::os::raw::c_void, + pub co_opcache_map: *mut ::std::os::raw::c_uchar, + pub co_opcache: *mut _PyOpcache, + pub co_opcache_flag: ::std::os::raw::c_int, + pub co_opcache_size: ::std::os::raw::c_uchar, +} +impl Default for PyCodeObject { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type PyFrameObject = _frame; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PySliceObject { + pub ob_base: PyObject, + pub start: *mut PyObject, + pub stop: *mut PyObject, + pub step: *mut PyObject, +} +impl Default for PySliceObject { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type PyThreadState = _ts; +pub type PyInterpreterState = _is; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PyWideStringList { + pub length: Py_ssize_t, + pub items: *mut *mut wchar_t, +} +impl Default for PyWideStringList { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct PyPreConfig { + pub _config_init: ::std::os::raw::c_int, + pub parse_argv: ::std::os::raw::c_int, + pub isolated: ::std::os::raw::c_int, + pub use_environment: ::std::os::raw::c_int, + pub configure_locale: ::std::os::raw::c_int, + pub coerce_c_locale: ::std::os::raw::c_int, + pub coerce_c_locale_warn: ::std::os::raw::c_int, + pub utf8_mode: ::std::os::raw::c_int, + pub dev_mode: ::std::os::raw::c_int, + pub allocator: ::std::os::raw::c_int, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PyConfig { + pub _config_init: ::std::os::raw::c_int, + pub isolated: ::std::os::raw::c_int, + pub use_environment: ::std::os::raw::c_int, + pub dev_mode: ::std::os::raw::c_int, + pub install_signal_handlers: ::std::os::raw::c_int, + pub use_hash_seed: ::std::os::raw::c_int, + pub hash_seed: ::std::os::raw::c_ulong, + pub faulthandler: ::std::os::raw::c_int, + pub tracemalloc: ::std::os::raw::c_int, + pub import_time: ::std::os::raw::c_int, + pub show_ref_count: ::std::os::raw::c_int, + pub dump_refs: ::std::os::raw::c_int, + pub malloc_stats: ::std::os::raw::c_int, + pub filesystem_encoding: *mut wchar_t, + pub filesystem_errors: *mut wchar_t, + pub pycache_prefix: *mut wchar_t, + pub parse_argv: ::std::os::raw::c_int, + pub orig_argv: PyWideStringList, + pub argv: PyWideStringList, + pub xoptions: PyWideStringList, + pub warnoptions: PyWideStringList, + pub site_import: ::std::os::raw::c_int, + pub bytes_warning: ::std::os::raw::c_int, + pub warn_default_encoding: ::std::os::raw::c_int, + pub inspect: ::std::os::raw::c_int, + pub interactive: ::std::os::raw::c_int, + pub optimization_level: ::std::os::raw::c_int, + pub parser_debug: ::std::os::raw::c_int, + pub write_bytecode: ::std::os::raw::c_int, + pub verbose: ::std::os::raw::c_int, + pub quiet: ::std::os::raw::c_int, + pub user_site_directory: ::std::os::raw::c_int, + pub configure_c_stdio: ::std::os::raw::c_int, + pub buffered_stdio: ::std::os::raw::c_int, + pub stdio_encoding: *mut wchar_t, + pub stdio_errors: *mut wchar_t, + pub check_hash_pycs_mode: *mut wchar_t, + pub pathconfig_warnings: ::std::os::raw::c_int, + pub program_name: *mut wchar_t, + pub pythonpath_env: *mut wchar_t, + pub home: *mut wchar_t, + pub platlibdir: *mut wchar_t, + pub module_search_paths_set: ::std::os::raw::c_int, + pub module_search_paths: PyWideStringList, + pub executable: *mut wchar_t, + pub base_executable: *mut wchar_t, + pub prefix: *mut wchar_t, + pub base_prefix: *mut wchar_t, + pub exec_prefix: *mut wchar_t, + pub base_exec_prefix: *mut wchar_t, + pub skip_source_first_line: ::std::os::raw::c_int, + pub run_command: *mut wchar_t, + pub run_module: *mut wchar_t, + pub run_filename: *mut wchar_t, + pub _install_importlib: ::std::os::raw::c_int, + pub _init_main: ::std::os::raw::c_int, + pub _isolated_interpreter: ::std::os::raw::c_int, +} +impl Default for PyConfig { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type Py_tracefunc = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut PyObject, + arg2: *mut PyFrameObject, + arg3: ::std::os::raw::c_int, + arg4: *mut PyObject, + ) -> ::std::os::raw::c_int, +>; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _cframe { + pub use_tracing: ::std::os::raw::c_int, + pub previous: *mut _cframe, +} +impl Default for _cframe { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type CFrame = _cframe; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _err_stackitem { + pub exc_type: *mut PyObject, + pub exc_value: *mut PyObject, + pub exc_traceback: *mut PyObject, + pub previous_item: *mut _err_stackitem, +} +impl Default for _err_stackitem { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type _PyErr_StackItem = _err_stackitem; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _ts { + pub prev: *mut _ts, + pub next: *mut _ts, + pub interp: *mut PyInterpreterState, + pub frame: *mut PyFrameObject, + pub recursion_depth: ::std::os::raw::c_int, + pub recursion_headroom: ::std::os::raw::c_int, + pub stackcheck_counter: ::std::os::raw::c_int, + pub tracing: ::std::os::raw::c_int, + pub cframe: *mut CFrame, + pub c_profilefunc: Py_tracefunc, + pub c_tracefunc: Py_tracefunc, + pub c_profileobj: *mut PyObject, + pub c_traceobj: *mut PyObject, + pub curexc_type: *mut PyObject, + pub curexc_value: *mut PyObject, + pub curexc_traceback: *mut PyObject, + pub exc_state: _PyErr_StackItem, + pub exc_info: *mut _PyErr_StackItem, + pub dict: *mut PyObject, + pub gilstate_counter: ::std::os::raw::c_int, + pub async_exc: *mut PyObject, + pub thread_id: ::std::os::raw::c_ulong, + pub trash_delete_nesting: ::std::os::raw::c_int, + pub trash_delete_later: *mut PyObject, + pub on_delete: ::std::option::Option, + pub on_delete_data: *mut ::std::os::raw::c_void, + pub coroutine_origin_tracking_depth: ::std::os::raw::c_int, + pub async_gen_firstiter: *mut PyObject, + pub async_gen_finalizer: *mut PyObject, + pub context: *mut PyObject, + pub context_ver: u64, + pub id: u64, + pub root_cframe: CFrame, +} +impl Default for _ts { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type _PyFrameEvalFunction = ::std::option::Option< + unsafe extern "C" fn( + tstate: *mut PyThreadState, + arg1: *mut PyFrameObject, + arg2: ::std::os::raw::c_int, + ) -> *mut PyObject, +>; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _xid { + pub data: *mut ::std::os::raw::c_void, + pub obj: *mut PyObject, + pub interp: i64, + pub new_object: ::std::option::Option *mut PyObject>, + pub free: ::std::option::Option, +} +impl Default for _xid { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type crossinterpdatafunc = ::std::option::Option< + unsafe extern "C" fn(arg1: *mut PyObject, arg2: *mut _xid) -> ::std::os::raw::c_int, +>; +pub type getter = ::std::option::Option< + unsafe extern "C" fn(arg1: *mut PyObject, arg2: *mut ::std::os::raw::c_void) -> *mut PyObject, +>; +pub type setter = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut PyObject, + arg2: *mut PyObject, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, +>; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PyGetSetDef { + pub name: *const ::std::os::raw::c_char, + pub get: getter, + pub set: setter, + pub doc: *const ::std::os::raw::c_char, + pub closure: *mut ::std::os::raw::c_void, +} +impl Default for PyGetSetDef { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PyMemberDef { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +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: ::std::os::raw::c_char, +} +impl Default for PyBaseExceptionObject { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type PyThread_type_lock = *mut ::std::os::raw::c_void; +pub type Py_tss_t = _Py_tss_t; +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct _Py_tss_t { + pub _is_initialized: ::std::os::raw::c_int, + pub _key: pthread_key_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _pycontextobject { + _unused: [u8; 0], +} +pub type PyContext = _pycontextobject; +pub type Py_AuditHookFunction = ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *mut PyObject, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, +>; +pub const _Py_error_handler__Py_ERROR_UNKNOWN: _Py_error_handler = 0; +pub const _Py_error_handler__Py_ERROR_STRICT: _Py_error_handler = 1; +pub const _Py_error_handler__Py_ERROR_SURROGATEESCAPE: _Py_error_handler = 2; +pub const _Py_error_handler__Py_ERROR_REPLACE: _Py_error_handler = 3; +pub const _Py_error_handler__Py_ERROR_IGNORE: _Py_error_handler = 4; +pub const _Py_error_handler__Py_ERROR_BACKSLASHREPLACE: _Py_error_handler = 5; +pub const _Py_error_handler__Py_ERROR_SURROGATEPASS: _Py_error_handler = 6; +pub const _Py_error_handler__Py_ERROR_XMLCHARREFREPLACE: _Py_error_handler = 7; +pub const _Py_error_handler__Py_ERROR_OTHER: _Py_error_handler = 8; +pub type _Py_error_handler = u32; +pub type PyFrameState = ::std::os::raw::c_schar; +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct PyTryBlock { + pub b_type: ::std::os::raw::c_int, + pub b_handler: ::std::os::raw::c_int, + pub b_level: ::std::os::raw::c_int, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _frame { + pub ob_base: PyVarObject, + pub f_back: *mut _frame, + pub f_code: *mut PyCodeObject, + pub f_builtins: *mut PyObject, + pub f_globals: *mut PyObject, + pub f_locals: *mut PyObject, + pub f_valuestack: *mut *mut PyObject, + pub f_trace: *mut PyObject, + pub f_stackdepth: ::std::os::raw::c_int, + pub f_trace_lines: ::std::os::raw::c_char, + pub f_trace_opcodes: ::std::os::raw::c_char, + pub f_gen: *mut PyObject, + pub f_lasti: ::std::os::raw::c_int, + pub f_lineno: ::std::os::raw::c_int, + pub f_iblock: ::std::os::raw::c_int, + pub f_state: PyFrameState, + pub f_blockstack: [PyTryBlock; 20usize], + pub f_localsplus: [*mut PyObject; 1usize], +} +impl Default for _frame { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PyDictKeyEntry { + pub me_hash: Py_hash_t, + pub me_key: *mut PyObject, + pub me_value: *mut PyObject, +} +impl Default for PyDictKeyEntry { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type dict_lookup_func = ::std::option::Option< + unsafe extern "C" fn( + mp: *mut PyDictObject, + key: *mut PyObject, + hash: Py_hash_t, + value_addr: *mut *mut PyObject, + ) -> Py_ssize_t, +>; +#[repr(C)] +#[derive(Debug)] +pub struct _dictkeysobject { + pub dk_refcnt: Py_ssize_t, + pub dk_size: Py_ssize_t, + pub dk_lookup: dict_lookup_func, + pub dk_usable: Py_ssize_t, + pub dk_nentries: Py_ssize_t, + pub dk_indices: __IncompleteArrayField<::std::os::raw::c_char>, +} +impl Default for _dictkeysobject { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +pub type atomic_int = u32; +pub type atomic_uintptr_t = usize; +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct _Py_atomic_address { + pub _value: atomic_uintptr_t, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct _Py_atomic_int { + pub _value: atomic_int, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _gil_runtime_state { + pub interval: ::std::os::raw::c_ulong, + pub last_holder: _Py_atomic_address, + pub locked: _Py_atomic_int, + pub switch_number: ::std::os::raw::c_ulong, + pub cond: pthread_cond_t, + pub mutex: pthread_mutex_t, + pub switch_cond: pthread_cond_t, + pub switch_mutex: pthread_mutex_t, +} +impl Default for _gil_runtime_state { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _ceval_runtime_state { + pub signals_pending: _Py_atomic_int, + pub gil: _gil_runtime_state, +} +impl Default for _ceval_runtime_state { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _gilstate_runtime_state { + pub check_enabled: ::std::os::raw::c_int, + pub tstate_current: _Py_atomic_address, + pub autoInterpreterState: *mut PyInterpreterState, + pub autoTSSkey: Py_tss_t, +} +impl Default for _gilstate_runtime_state { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _Py_AuditHookEntry { + pub next: *mut _Py_AuditHookEntry, + pub hookCFunction: Py_AuditHookFunction, + pub userData: *mut ::std::os::raw::c_void, +} +impl Default for _Py_AuditHookEntry { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _Py_unicode_runtime_ids { + pub lock: PyThread_type_lock, + pub next_index: Py_ssize_t, +} +impl Default for _Py_unicode_runtime_ids { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pyruntimestate { + pub preinitializing: ::std::os::raw::c_int, + pub preinitialized: ::std::os::raw::c_int, + pub core_initialized: ::std::os::raw::c_int, + pub initialized: ::std::os::raw::c_int, + pub _finalizing: _Py_atomic_address, + pub interpreters: pyruntimestate_pyinterpreters, + pub xidregistry: pyruntimestate__xidregistry, + pub main_thread: ::std::os::raw::c_ulong, + pub exitfuncs: [::std::option::Option; 32usize], + pub nexitfuncs: ::std::os::raw::c_int, + pub ceval: _ceval_runtime_state, + pub gilstate: _gilstate_runtime_state, + pub preconfig: PyPreConfig, + pub open_code_hook: Py_OpenCodeHookFunction, + pub open_code_userdata: *mut ::std::os::raw::c_void, + pub audit_hook_head: *mut _Py_AuditHookEntry, + pub unicode_ids: _Py_unicode_runtime_ids, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pyruntimestate_pyinterpreters { + pub mutex: PyThread_type_lock, + pub head: *mut PyInterpreterState, + pub main: *mut PyInterpreterState, + pub next_id: i64, +} +impl Default for pyruntimestate_pyinterpreters { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pyruntimestate__xidregistry { + pub mutex: PyThread_type_lock, + pub head: *mut _xidregitem, +} +impl Default for pyruntimestate__xidregistry { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +impl Default for pyruntimestate { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ast_state { + pub initialized: ::std::os::raw::c_int, + pub AST_type: *mut PyObject, + pub Add_singleton: *mut PyObject, + pub Add_type: *mut PyObject, + pub And_singleton: *mut PyObject, + pub And_type: *mut PyObject, + pub AnnAssign_type: *mut PyObject, + pub Assert_type: *mut PyObject, + pub Assign_type: *mut PyObject, + pub AsyncFor_type: *mut PyObject, + pub AsyncFunctionDef_type: *mut PyObject, + pub AsyncWith_type: *mut PyObject, + pub Attribute_type: *mut PyObject, + pub AugAssign_type: *mut PyObject, + pub Await_type: *mut PyObject, + pub BinOp_type: *mut PyObject, + pub BitAnd_singleton: *mut PyObject, + pub BitAnd_type: *mut PyObject, + pub BitOr_singleton: *mut PyObject, + pub BitOr_type: *mut PyObject, + pub BitXor_singleton: *mut PyObject, + pub BitXor_type: *mut PyObject, + pub BoolOp_type: *mut PyObject, + pub Break_type: *mut PyObject, + pub Call_type: *mut PyObject, + pub ClassDef_type: *mut PyObject, + pub Compare_type: *mut PyObject, + pub Constant_type: *mut PyObject, + pub Continue_type: *mut PyObject, + pub Del_singleton: *mut PyObject, + pub Del_type: *mut PyObject, + pub Delete_type: *mut PyObject, + pub DictComp_type: *mut PyObject, + pub Dict_type: *mut PyObject, + pub Div_singleton: *mut PyObject, + pub Div_type: *mut PyObject, + pub Eq_singleton: *mut PyObject, + pub Eq_type: *mut PyObject, + pub ExceptHandler_type: *mut PyObject, + pub Expr_type: *mut PyObject, + pub Expression_type: *mut PyObject, + pub FloorDiv_singleton: *mut PyObject, + pub FloorDiv_type: *mut PyObject, + pub For_type: *mut PyObject, + pub FormattedValue_type: *mut PyObject, + pub FunctionDef_type: *mut PyObject, + pub FunctionType_type: *mut PyObject, + pub GeneratorExp_type: *mut PyObject, + pub Global_type: *mut PyObject, + pub GtE_singleton: *mut PyObject, + pub GtE_type: *mut PyObject, + pub Gt_singleton: *mut PyObject, + pub Gt_type: *mut PyObject, + pub IfExp_type: *mut PyObject, + pub If_type: *mut PyObject, + pub ImportFrom_type: *mut PyObject, + pub Import_type: *mut PyObject, + pub In_singleton: *mut PyObject, + pub In_type: *mut PyObject, + pub Interactive_type: *mut PyObject, + pub Invert_singleton: *mut PyObject, + pub Invert_type: *mut PyObject, + pub IsNot_singleton: *mut PyObject, + pub IsNot_type: *mut PyObject, + pub Is_singleton: *mut PyObject, + pub Is_type: *mut PyObject, + pub JoinedStr_type: *mut PyObject, + pub LShift_singleton: *mut PyObject, + pub LShift_type: *mut PyObject, + pub Lambda_type: *mut PyObject, + pub ListComp_type: *mut PyObject, + pub List_type: *mut PyObject, + pub Load_singleton: *mut PyObject, + pub Load_type: *mut PyObject, + pub LtE_singleton: *mut PyObject, + pub LtE_type: *mut PyObject, + pub Lt_singleton: *mut PyObject, + pub Lt_type: *mut PyObject, + pub MatMult_singleton: *mut PyObject, + pub MatMult_type: *mut PyObject, + pub MatchAs_type: *mut PyObject, + pub MatchClass_type: *mut PyObject, + pub MatchMapping_type: *mut PyObject, + pub MatchOr_type: *mut PyObject, + pub MatchSequence_type: *mut PyObject, + pub MatchSingleton_type: *mut PyObject, + pub MatchStar_type: *mut PyObject, + pub MatchValue_type: *mut PyObject, + pub Match_type: *mut PyObject, + pub Mod_singleton: *mut PyObject, + pub Mod_type: *mut PyObject, + pub Module_type: *mut PyObject, + pub Mult_singleton: *mut PyObject, + pub Mult_type: *mut PyObject, + pub Name_type: *mut PyObject, + pub NamedExpr_type: *mut PyObject, + pub Nonlocal_type: *mut PyObject, + pub NotEq_singleton: *mut PyObject, + pub NotEq_type: *mut PyObject, + pub NotIn_singleton: *mut PyObject, + pub NotIn_type: *mut PyObject, + pub Not_singleton: *mut PyObject, + pub Not_type: *mut PyObject, + pub Or_singleton: *mut PyObject, + pub Or_type: *mut PyObject, + pub Pass_type: *mut PyObject, + pub Pow_singleton: *mut PyObject, + pub Pow_type: *mut PyObject, + pub RShift_singleton: *mut PyObject, + pub RShift_type: *mut PyObject, + pub Raise_type: *mut PyObject, + pub Return_type: *mut PyObject, + pub SetComp_type: *mut PyObject, + pub Set_type: *mut PyObject, + pub Slice_type: *mut PyObject, + pub Starred_type: *mut PyObject, + pub Store_singleton: *mut PyObject, + pub Store_type: *mut PyObject, + pub Sub_singleton: *mut PyObject, + pub Sub_type: *mut PyObject, + pub Subscript_type: *mut PyObject, + pub Try_type: *mut PyObject, + pub Tuple_type: *mut PyObject, + pub TypeIgnore_type: *mut PyObject, + pub UAdd_singleton: *mut PyObject, + pub UAdd_type: *mut PyObject, + pub USub_singleton: *mut PyObject, + pub USub_type: *mut PyObject, + pub UnaryOp_type: *mut PyObject, + pub While_type: *mut PyObject, + pub With_type: *mut PyObject, + pub YieldFrom_type: *mut PyObject, + pub Yield_type: *mut PyObject, + pub __dict__: *mut PyObject, + pub __doc__: *mut PyObject, + pub __match_args__: *mut PyObject, + pub __module__: *mut PyObject, + pub _attributes: *mut PyObject, + pub _fields: *mut PyObject, + pub alias_type: *mut PyObject, + pub annotation: *mut PyObject, + pub arg: *mut PyObject, + pub arg_type: *mut PyObject, + pub args: *mut PyObject, + pub argtypes: *mut PyObject, + pub arguments_type: *mut PyObject, + pub asname: *mut PyObject, + pub ast: *mut PyObject, + pub attr: *mut PyObject, + pub bases: *mut PyObject, + pub body: *mut PyObject, + pub boolop_type: *mut PyObject, + pub cases: *mut PyObject, + pub cause: *mut PyObject, + pub cls: *mut PyObject, + pub cmpop_type: *mut PyObject, + pub col_offset: *mut PyObject, + pub comparators: *mut PyObject, + pub comprehension_type: *mut PyObject, + pub context_expr: *mut PyObject, + pub conversion: *mut PyObject, + pub ctx: *mut PyObject, + pub decorator_list: *mut PyObject, + pub defaults: *mut PyObject, + pub elt: *mut PyObject, + pub elts: *mut PyObject, + pub end_col_offset: *mut PyObject, + pub end_lineno: *mut PyObject, + pub exc: *mut PyObject, + pub excepthandler_type: *mut PyObject, + pub expr_context_type: *mut PyObject, + pub expr_type: *mut PyObject, + pub finalbody: *mut PyObject, + pub format_spec: *mut PyObject, + pub func: *mut PyObject, + pub generators: *mut PyObject, + pub guard: *mut PyObject, + pub handlers: *mut PyObject, + pub id: *mut PyObject, + pub ifs: *mut PyObject, + pub is_async: *mut PyObject, + pub items: *mut PyObject, + pub iter: *mut PyObject, + pub key: *mut PyObject, + pub keys: *mut PyObject, + pub keyword_type: *mut PyObject, + pub keywords: *mut PyObject, + pub kind: *mut PyObject, + pub kw_defaults: *mut PyObject, + pub kwarg: *mut PyObject, + pub kwd_attrs: *mut PyObject, + pub kwd_patterns: *mut PyObject, + pub kwonlyargs: *mut PyObject, + pub left: *mut PyObject, + pub level: *mut PyObject, + pub lineno: *mut PyObject, + pub lower: *mut PyObject, + pub match_case_type: *mut PyObject, + pub mod_type: *mut PyObject, + pub module: *mut PyObject, + pub msg: *mut PyObject, + pub name: *mut PyObject, + pub names: *mut PyObject, + pub op: *mut PyObject, + pub operand: *mut PyObject, + pub operator_type: *mut PyObject, + pub ops: *mut PyObject, + pub optional_vars: *mut PyObject, + pub orelse: *mut PyObject, + pub pattern: *mut PyObject, + pub pattern_type: *mut PyObject, + pub patterns: *mut PyObject, + pub posonlyargs: *mut PyObject, + pub rest: *mut PyObject, + pub returns: *mut PyObject, + pub right: *mut PyObject, + pub simple: *mut PyObject, + pub slice: *mut PyObject, + pub step: *mut PyObject, + pub stmt_type: *mut PyObject, + pub subject: *mut PyObject, + pub tag: *mut PyObject, + pub target: *mut PyObject, + pub targets: *mut PyObject, + pub test: *mut PyObject, + pub type_: *mut PyObject, + pub type_comment: *mut PyObject, + pub type_ignore_type: *mut PyObject, + pub type_ignores: *mut PyObject, + pub unaryop_type: *mut PyObject, + pub upper: *mut PyObject, + pub value: *mut PyObject, + pub values: *mut PyObject, + pub vararg: *mut PyObject, + pub withitem_type: *mut PyObject, +} +impl Default for ast_state { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct PyGC_Head { + pub _gc_next: usize, + pub _gc_prev: usize, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct gc_generation { + pub head: PyGC_Head, + pub threshold: ::std::os::raw::c_int, + pub count: ::std::os::raw::c_int, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct gc_generation_stats { + pub collections: Py_ssize_t, + pub collected: Py_ssize_t, + pub uncollectable: Py_ssize_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _gc_runtime_state { + pub trash_delete_later: *mut PyObject, + pub trash_delete_nesting: ::std::os::raw::c_int, + pub enabled: ::std::os::raw::c_int, + pub debug: ::std::os::raw::c_int, + pub generations: [gc_generation; 3usize], + pub generation0: *mut PyGC_Head, + pub permanent_generation: gc_generation, + pub generation_stats: [gc_generation_stats; 3usize], + pub collecting: ::std::os::raw::c_int, + pub garbage: *mut PyObject, + pub callbacks: *mut PyObject, + pub long_lived_total: Py_ssize_t, + pub long_lived_pending: Py_ssize_t, +} +impl Default for _gc_runtime_state { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _warnings_runtime_state { + pub filters: *mut PyObject, + pub once_registry: *mut PyObject, + pub default_action: *mut PyObject, + pub filters_version: ::std::os::raw::c_long, +} +impl Default for _warnings_runtime_state { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _pending_calls { + pub lock: PyThread_type_lock, + pub calls_to_do: _Py_atomic_int, + pub async_exc: ::std::os::raw::c_int, + pub calls: [_pending_calls__bindgen_ty_1; 32usize], + pub first: ::std::os::raw::c_int, + pub last: ::std::os::raw::c_int, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _pending_calls__bindgen_ty_1 { + pub func: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int, + >, + pub arg: *mut ::std::os::raw::c_void, +} +impl Default for _pending_calls__bindgen_ty_1 { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +impl Default for _pending_calls { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _ceval_state { + pub recursion_limit: ::std::os::raw::c_int, + pub eval_breaker: _Py_atomic_int, + pub gil_drop_request: _Py_atomic_int, + pub pending: _pending_calls, +} +impl Default for _ceval_state { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _Py_unicode_fs_codec { + pub encoding: *mut ::std::os::raw::c_char, + pub utf8: ::std::os::raw::c_int, + pub errors: *mut ::std::os::raw::c_char, + pub error_handler: _Py_error_handler, +} +impl Default for _Py_unicode_fs_codec { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _Py_bytes_state { + pub empty_string: *mut PyObject, + pub characters: [*mut PyBytesObject; 256usize], +} +impl Default for _Py_bytes_state { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _Py_unicode_ids { + pub size: Py_ssize_t, + pub array: *mut *mut PyObject, +} +impl Default for _Py_unicode_ids { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _Py_unicode_state { + pub empty_string: *mut PyObject, + pub latin1: [*mut PyObject; 256usize], + pub fs_codec: _Py_unicode_fs_codec, + pub interned: *mut PyObject, + pub ids: _Py_unicode_ids, +} +impl Default for _Py_unicode_state { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _Py_float_state { + pub numfree: ::std::os::raw::c_int, + pub free_list: *mut PyFloatObject, +} +impl Default for _Py_float_state { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _Py_tuple_state { + pub free_list: [*mut PyTupleObject; 20usize], + pub numfree: [::std::os::raw::c_int; 20usize], +} +impl Default for _Py_tuple_state { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _Py_list_state { + pub free_list: [*mut PyListObject; 80usize], + pub numfree: ::std::os::raw::c_int, +} +impl Default for _Py_list_state { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _Py_dict_state { + pub free_list: [*mut PyDictObject; 80usize], + pub numfree: ::std::os::raw::c_int, + pub keys_free_list: [*mut PyDictKeysObject; 80usize], + pub keys_numfree: ::std::os::raw::c_int, +} +impl Default for _Py_dict_state { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _Py_frame_state { + pub free_list: *mut PyFrameObject, + pub numfree: ::std::os::raw::c_int, +} +impl Default for _Py_frame_state { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _Py_async_gen_state { + pub value_freelist: [*mut _PyAsyncGenWrappedValue; 80usize], + pub value_numfree: ::std::os::raw::c_int, + pub asend_freelist: [*mut PyAsyncGenASend; 80usize], + pub asend_numfree: ::std::os::raw::c_int, +} +impl Default for _Py_async_gen_state { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _Py_context_state { + pub freelist: *mut PyContext, + pub numfree: ::std::os::raw::c_int, +} +impl Default for _Py_context_state { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _Py_exc_state { + pub errnomap: *mut PyObject, + pub memerrors_freelist: *mut PyBaseExceptionObject, + pub memerrors_numfree: ::std::os::raw::c_int, +} +impl Default for _Py_exc_state { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct atexit_callback { + pub func: *mut PyObject, + pub args: *mut PyObject, + pub kwargs: *mut PyObject, +} +impl Default for atexit_callback { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct atexit_state { + pub callbacks: *mut *mut atexit_callback, + pub ncallbacks: ::std::os::raw::c_int, + pub callback_len: ::std::os::raw::c_int, +} +impl Default for atexit_state { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct type_cache_entry { + pub version: ::std::os::raw::c_uint, + pub name: *mut PyObject, + pub value: *mut PyObject, +} +impl Default for type_cache_entry { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct type_cache { + pub hashtable: [type_cache_entry; 4096usize], +} +impl Default for type_cache { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _is { + pub next: *mut _is, + pub tstate_head: *mut _ts, + pub runtime: *mut pyruntimestate, + pub id: i64, + pub id_refcount: i64, + pub requires_idref: ::std::os::raw::c_int, + pub id_mutex: PyThread_type_lock, + pub finalizing: ::std::os::raw::c_int, + pub ceval: _ceval_state, + pub gc: _gc_runtime_state, + pub modules: *mut PyObject, + pub modules_by_index: *mut PyObject, + pub sysdict: *mut PyObject, + pub builtins: *mut PyObject, + pub importlib: *mut PyObject, + pub num_threads: ::std::os::raw::c_long, + pub pythread_stacksize: usize, + pub codec_search_path: *mut PyObject, + pub codec_search_cache: *mut PyObject, + pub codec_error_registry: *mut PyObject, + pub codecs_initialized: ::std::os::raw::c_int, + pub config: PyConfig, + pub dlopenflags: ::std::os::raw::c_int, + pub dict: *mut PyObject, + pub builtins_copy: *mut PyObject, + pub import_func: *mut PyObject, + pub eval_frame: _PyFrameEvalFunction, + pub co_extra_user_count: Py_ssize_t, + pub co_extra_freefuncs: [freefunc; 255usize], + pub before_forkers: *mut PyObject, + pub after_forkers_parent: *mut PyObject, + pub after_forkers_child: *mut PyObject, + pub tstate_next_unique_id: u64, + pub warnings: _warnings_runtime_state, + pub atexit: atexit_state, + pub audit_hooks: *mut PyObject, + pub small_ints: [*mut PyLongObject; 262usize], + pub bytes: _Py_bytes_state, + pub unicode: _Py_unicode_state, + pub float_state: _Py_float_state, + pub slice_cache: *mut PySliceObject, + pub tuple: _Py_tuple_state, + pub list: _Py_list_state, + pub dict_state: _Py_dict_state, + pub frame: _Py_frame_state, + pub async_gen: _Py_async_gen_state, + pub context: _Py_context_state, + pub exc_state: _Py_exc_state, + pub ast: ast_state, + pub type_cache: type_cache, +} +impl Default for _is { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _xidregitem { + pub cls: *mut PyTypeObject, + pub getdata: crossinterpdatafunc, + pub next: *mut _xidregitem, +} +impl Default for _xidregitem { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct _PyAsyncGenWrappedValue { + pub _address: u8, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct PyAsyncGenASend { + pub _address: u8, +} diff --git a/src/python_interpreters.rs b/src/python_interpreters.rs index 4a042754..725ddade 100644 --- a/src/python_interpreters.rs +++ b/src/python_interpreters.rs @@ -9,7 +9,8 @@ This means we can't dereference them directly. // these bindings are automatically generated by rust bindgen // using the generate_bindings.py script -use crate::python_bindings::{v2_7_15, v3_3_7, v3_5_5, v3_6_6, v3_7_0, v3_8_0, v3_9_5}; +use crate::python_bindings::{v2_7_15, v3_3_7, v3_5_5, v3_6_6, v3_7_0, v3_8_0, v3_9_5, v3_10_0}; + use std; pub trait InterpreterState { @@ -47,11 +48,13 @@ pub trait CodeObject { fn name(&self) -> * mut Self::StringObject; fn filename(&self) -> * mut Self::StringObject; - fn lnotab(&self) -> * mut Self::BytesObject; + fn line_table(&self) -> * mut Self::BytesObject; fn first_lineno(&self) -> i32; fn nlocals(&self) -> i32; fn argcount(&self) -> i32; fn varnames(&self) -> * mut Self::TupleObject; + + fn get_line_number(&self, lasti: i32, table: &[u8]) -> i32; } pub trait BytesObject { @@ -124,6 +127,22 @@ macro_rules! PythonCommonImpl { fn back(&self) -> * mut Self { self.f_back } } + impl Object for $py::PyObject { + type TypeObject = $py::PyTypeObject; + fn ob_type(&self) -> * mut Self::TypeObject { self.ob_type as * mut Self::TypeObject } + } + + impl TypeObject for $py::PyTypeObject { + fn name(&self) -> *const ::std::os::raw::c_char { self.tp_name } + fn dictoffset(&self) -> isize { self.tp_dictoffset } + fn flags(&self) -> usize { self.tp_flags as usize } + } + ) +} + +// We can use this up until python3.10 - where code object lnotab attribute is deprecated +macro_rules! PythonCodeObjectImpl { + ($py: ident, $bytesobject: ident, $stringobject: ident) => ( impl CodeObject for $py::PyCodeObject { type BytesObject = $py::$bytesobject; type StringObject = $py::$stringobject; @@ -131,22 +150,36 @@ macro_rules! PythonCommonImpl { fn name(&self) -> * mut Self::StringObject { self.co_name as * mut Self::StringObject } fn filename(&self) -> * mut Self::StringObject { self.co_filename as * mut Self::StringObject } - fn lnotab(&self) -> * mut Self::BytesObject { self.co_lnotab as * mut Self::BytesObject } + fn line_table(&self) -> * mut Self::BytesObject { self.co_lnotab as * mut Self::BytesObject } fn first_lineno(&self) -> i32 { self.co_firstlineno } fn nlocals(&self) -> i32 { self.co_nlocals } fn argcount(&self) -> i32 { self.co_argcount } fn varnames(&self) -> * mut Self::TupleObject { self.co_varnames as * mut Self::TupleObject } - } - impl Object for $py::PyObject { - type TypeObject = $py::PyTypeObject; - fn ob_type(&self) -> * mut Self::TypeObject { self.ob_type as * mut Self::TypeObject } - } - - impl TypeObject for $py::PyTypeObject { - fn name(&self) -> *const ::std::os::raw::c_char { self.tp_name } - fn dictoffset(&self) -> isize { self.tp_dictoffset } - fn flags(&self) -> usize { self.tp_flags as usize } + fn get_line_number(&self, lasti: i32, table: &[u8]) -> i32 { + // unpack the line table. format is specified here: + // https://github.com/python/cpython/blob/3.9/Objects/lnotab_notes.txt + let size = table.len(); + let mut i = 0; + let mut line_number: i32 = self.first_lineno(); + let mut bytecode_address: i32 = 0; + while (i + 1) < size { + bytecode_address += i32::from(table[i]); + if bytecode_address > lasti { + break; + } + + let mut increment = i32::from(table[i + 1]); + // Handle negative line increments in the line number table - as shown here: + // https://github.com/python/cpython/blob/143a97f6/Objects/lnotab_notes.txt#L48-L49 + if increment >= 0x80 { + increment -= 0x100; + } + line_number += increment; + i += 2; + } + line_number + } } ) } @@ -193,32 +226,89 @@ macro_rules! Python3Impl { } ) } +// Python 3.10 +PythonCommonImpl!(v3_10_0, PyBytesObject, PyUnicodeObject); +impl CodeObject for v3_10_0::PyCodeObject { + type BytesObject = v3_10_0::PyBytesObject; + type StringObject = v3_10_0::PyUnicodeObject; + type TupleObject = v3_10_0::PyTupleObject; + + fn name(&self) -> * mut Self::StringObject { self.co_name as * mut Self::StringObject } + fn filename(&self) -> * mut Self::StringObject { self.co_filename as * mut Self::StringObject } + fn line_table(&self) -> * mut Self::BytesObject { self.co_linetable as * mut Self::BytesObject } + fn first_lineno(&self) -> i32 { self.co_firstlineno } + fn nlocals(&self) -> i32 { self.co_nlocals } + fn argcount(&self) -> i32 { self.co_argcount } + fn varnames(&self) -> * mut Self::TupleObject { self.co_varnames as * mut Self::TupleObject } + + fn get_line_number(&self, lasti: i32, table: &[u8]) -> i32 { + // in Python 3.10 we need to double the lasti instruction value here (and no I don't know why) + // https://github.com/python/cpython/blob/7b88f63e1dd4006b1a08b9c9f087dd13449ecc76/Python/ceval.c#L5999 + // Whereas in python versions up to 3.9 we didn't. + // https://github.com/python/cpython/blob/3.9/Python/ceval.c#L4713-L4714 + let lasti = lasti * 2; + + // unpack the line table. format is specified here: + // https://github.com/python/cpython/blob/3.10/Objects/lnotab_notes.txt + let size = table.len(); + let mut i = 0; + let mut line_number: i32 = self.first_lineno(); + let mut bytecode_address: i32 = 0; + while (i + 1) < size { + let delta: u8 = table[i]; + let line_delta: i8 = unsafe { std::mem::transmute(table[i + 1]) }; + i += 2; + + if line_delta == -128 { + continue; + } + + line_number += i32::from(line_delta); + bytecode_address += i32::from(delta); + if bytecode_address > lasti { + break; + } + } + + line_number + } +} + +Python3Impl!(v3_10_0); + // Python 3.9 PythonCommonImpl!(v3_9_5, PyBytesObject, PyUnicodeObject); +PythonCodeObjectImpl!(v3_9_5, PyBytesObject, PyUnicodeObject); Python3Impl!(v3_9_5); // Python 3.8 PythonCommonImpl!(v3_8_0, PyBytesObject, PyUnicodeObject); +PythonCodeObjectImpl!(v3_8_0, PyBytesObject, PyUnicodeObject); Python3Impl!(v3_8_0); // Python 3.7 PythonCommonImpl!(v3_7_0, PyBytesObject, PyUnicodeObject); +PythonCodeObjectImpl!(v3_7_0, PyBytesObject, PyUnicodeObject); Python3Impl!(v3_7_0); // Python 3.6 PythonCommonImpl!(v3_6_6, PyBytesObject, PyUnicodeObject); +PythonCodeObjectImpl!(v3_6_6, PyBytesObject, PyUnicodeObject); Python3Impl!(v3_6_6); // python 3.5 and python 3.4 PythonCommonImpl!(v3_5_5, PyBytesObject, PyUnicodeObject); +PythonCodeObjectImpl!(v3_5_5, PyBytesObject, PyUnicodeObject); Python3Impl!(v3_5_5); // python 3.3 PythonCommonImpl!(v3_3_7, PyBytesObject, PyUnicodeObject); +PythonCodeObjectImpl!(v3_3_7, PyBytesObject, PyUnicodeObject); Python3Impl!(v3_3_7); // Python 2.7 PythonCommonImpl!(v2_7_15, PyStringObject, PyStringObject); +PythonCodeObjectImpl!(v2_7_15, PyStringObject, PyStringObject); impl BytesObject for v2_7_15::PyStringObject { fn size(&self) -> usize { self.ob_size as usize } fn address(&self, base: usize) -> usize { base + offset_of(self, &self.ob_sval) } diff --git a/src/python_spy.rs b/src/python_spy.rs index ef5f9bec..2d4aa0fa 100644 --- a/src/python_spy.rs +++ b/src/python_spy.rs @@ -21,7 +21,7 @@ use crate::binary_parser::{parse_binary, BinaryInfo}; use crate::config::{Config, LockingStrategy, LineNo}; #[cfg(unwind)] use crate::native_stack_trace::NativeStack; -use crate::python_bindings::{pyruntime, v2_7_15, v3_3_7, v3_5_5, v3_6_6, v3_7_0, v3_8_0, v3_9_5}; +use crate::python_bindings::{pyruntime, v2_7_15, v3_3_7, v3_5_5, v3_6_6, v3_7_0, v3_8_0, v3_9_5, v3_10_0}; use crate::python_interpreters::{self, InterpreterState, ThreadState}; use crate::python_threading::thread_name_lookup; use crate::stack_trace::{StackTrace, get_stack_traces, get_stack_trace}; @@ -88,7 +88,7 @@ impl PythonSpy { // lets us figure out which thread has the GIL let threadstate_address = match version { - Version{major: 3, minor: 7..=9, ..} => { + Version{major: 3, minor: 7..=10, ..} => { match python_info.get_symbol("_PyRuntime") { Some(&addr) => { if let Some(offset) = pyruntime::get_tstate_current_offset(&version) { @@ -189,6 +189,7 @@ impl PythonSpy { } Version{major: 3, minor: 8, ..} => self._get_stack_traces::(), Version{major: 3, minor: 9, ..} => self._get_stack_traces::(), + Version{major: 3, minor: 10, ..} => self._get_stack_traces::(), _ => Err(format_err!("Unsupported version of Python: {}", self.version)), } } @@ -580,7 +581,7 @@ fn get_interpreter_address(python_info: &PythonProcessInfo, // get the address of the main PyInterpreterState object from loaded symbols if we can // (this tends to be faster than scanning through the bss section) match version { - Version{major: 3, minor: 7..=9, ..} => { + Version{major: 3, minor: 7..=10, ..} => { if let Some(&addr) = python_info.get_symbol("_PyRuntime") { let addr = process.copy_struct(addr as usize + pyruntime::get_interp_head_offset(&version))?; @@ -702,6 +703,7 @@ fn check_interpreter_addresses(addrs: &[usize], }, Version{major: 3, minor: 8, ..} => check::(addrs, maps, process), Version{major: 3, minor: 9, ..} => check::(addrs, maps, process), + Version{major: 3, minor: 10, ..} => check::(addrs, maps, process), _ => Err(format_err!("Unsupported version of Python: {}", version)) } } @@ -925,7 +927,7 @@ pub fn get_windows_python_symbols(pid: Pid, filename: &str, offset: u64) -> std: #[cfg(any(target_os="linux", target_os="freebsd"))] pub fn is_python_lib(pathname: &str) -> bool { lazy_static! { - static ref RE: Regex = Regex::new(r"/libpython\d.\d(m|d|u)?.so").unwrap(); + static ref RE: Regex = Regex::new(r"/libpython\d.\d\d?(m|d|u)?.so").unwrap(); } RE.is_match(pathname) } @@ -933,7 +935,7 @@ pub fn is_python_lib(pathname: &str) -> bool { #[cfg(target_os="macos")] pub fn is_python_lib(pathname: &str) -> bool { lazy_static! { - static ref RE: Regex = Regex::new(r"/libpython\d.\d(m|d|u)?.(dylib|so)$").unwrap(); + static ref RE: Regex = Regex::new(r"/libpython\d.\d\d?(m|d|u)?.(dylib|so)$").unwrap(); } RE.is_match(pathname) || is_python_framework(pathname) } @@ -941,7 +943,7 @@ pub fn is_python_lib(pathname: &str) -> bool { #[cfg(windows)] pub fn is_python_lib(pathname: &str) -> bool { lazy_static! { - static ref RE: Regex = RegexBuilder::new(r"\\python\d\d(m|d|u)?.dll$").case_insensitive(true).build().unwrap(); + static ref RE: Regex = RegexBuilder::new(r"\\python\d\d\d?(m|d|u)?.dll$").case_insensitive(true).build().unwrap(); } RE.is_match(pathname) } diff --git a/src/python_threading.rs b/src/python_threading.rs index 47396450..f84cabbd 100644 --- a/src/python_threading.rs +++ b/src/python_threading.rs @@ -64,6 +64,7 @@ pub fn thread_name_lookup(process: &PythonSpy) -> Option> { Version{major: 3, minor: 7, ..} => _thread_name_lookup::(&process), Version{major: 3, minor: 8, ..} => _thread_name_lookup::(&process), Version{major: 3, minor: 9, ..} => _thread_name_lookup::(&process), + Version{major: 3, minor: 10, ..} => _thread_name_lookup::(&process), _ => return None }; err.ok() diff --git a/src/stack_trace.rs b/src/stack_trace.rs index 16f87fe9..7161802d 100644 --- a/src/stack_trace.rs +++ b/src/stack_trace.rs @@ -98,7 +98,7 @@ pub fn get_stack_trace(thread: &T, process: &Process, copy_locals: bool, line LineNo::NoLine => 0, LineNo::FirstLineNo => code.first_lineno(), LineNo::LastInstruction => match get_line_number(&code, frame.lasti(), process) { - Ok(line) => line, + Ok(line) => line, Err(e) => { // Failling to get the line number really shouldn't be fatal here, but // can happen in extreme cases (https://github.com/benfred/py-spy/issues/164) @@ -152,33 +152,11 @@ impl StackTrace { /// Returns the line number from a PyCodeObject (given the lasti index from a PyFrameObject) fn get_line_number(code: &C, lasti: i32, process: &P) -> Result { - let table = copy_bytes(code.lnotab(), process).context("Failed to copy line number table")?; - - // unpack the line table. format is specified here: - // https://github.com/python/cpython/blob/master/Objects/lnotab_notes.txt - let size = table.len(); - let mut i = 0; - let mut line_number: i32 = code.first_lineno(); - let mut bytecode_address: i32 = 0; - while (i + 1) < size { - bytecode_address += i32::from(table[i]); - if bytecode_address > lasti { - break; - } - - let mut increment = i32::from(table[i + 1]); - // Handle negative line increments in the line number table - as shown here: - // https://github.com/python/cpython/blob/143a97f6/Objects/lnotab_notes.txt#L48-L49 - if increment >= 0x80 { - increment -= 0x100; - } - line_number += increment; - i += 2; - } - - Ok(line_number) + let table = copy_bytes(code.line_table(), process).context("Failed to copy line number table")?; + Ok(code.get_line_number(lasti, &table)) } + fn get_locals(code: &C, frameptr: *const F, frame: &F, process: &P) -> Result, Error> { let local_count = code.nlocals() as usize; diff --git a/src/version.rs b/src/version.rs index a183c335..fbda498a 100644 --- a/src/version.rs +++ b/src/version.rs @@ -16,7 +16,7 @@ pub struct Version { impl Version { pub fn scan_bytes(data: &[u8]) -> Result { lazy_static! { - static ref RE: Regex = Regex::new(r"((2|3)\.(3|4|5|6|7|8|9)\.(\d{1,2}))((a|b|c|rc)\d{1,2})?\+? (.{1,64})").unwrap(); + static ref RE: Regex = Regex::new(r"((2|3)\.(3|4|5|6|7|8|9|10)\.(\d{1,2}))((a|b|c|rc)\d{1,2})?\+? (.{1,64})").unwrap(); } if let Some(cap) = RE.captures_iter(data).next() { @@ -67,6 +67,9 @@ mod tests { let version = Version::scan_bytes(b"Python 3.7.0rc1 (v3.7.0rc1:dfad352267, Jul 20 2018, 13:27:54)").unwrap(); assert_eq!(version, Version{major: 3, minor: 7, patch: 0, release_flags: "rc1".to_owned()}); + let version = Version::scan_bytes(b"Python 3.10.0rc1 (tags/v3.10.0rc1, Aug 28 2021, 18:25:40)").unwrap(); + assert_eq!(version, Version{major: 3, minor: 10, patch: 0, release_flags: "rc1".to_owned()}); + let version = Version::scan_bytes(b"1.7.0rc1 (v1.7.0rc1:dfad352267, Jul 20 2018, 13:27:54)"); assert!(version.is_err(), "don't match unsupported ");