Remove PyIter_Check, PyIndex_Check under abi3 for Python < 3.8
While these are defined as macros in the Python C API, they rely on access to the PyTypeObject structure, which is not part of the limited API for those versions.
This commit is contained in:
parent
60848f94e4
commit
d278aaff54
|
@ -11,7 +11,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||
- Add #[pyo3(from_py_with = "...")]` attribute for function arguments and struct fields to override the default from-Python conversion. [#1411](https://github.com/PyO3/pyo3/pull/1411)
|
||||
- Add FFI definition `PyCFunction_CheckExact` for Python 3.9 and later. [#1425](https://github.com/PyO3/pyo3/pull/1425)
|
||||
- Add FFI definition `Py_IS_TYPE`. [#1429](https://github.com/PyO3/pyo3/pull/1429)
|
||||
- Implement `PyTryFrom` for `PyIterator` for Python 3.7 and earlier with the `abi3` feature. [#1436](https://github.com/PyO3/pyo3/pull/1436)
|
||||
|
||||
### Changed
|
||||
- Change `PyTimeAcces::get_fold()` to return a `bool` instead of a `u8`. [#1397](https://github.com/PyO3/pyo3/pull/1397)
|
||||
|
@ -31,7 +30,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||
- Remove FFI definition `PyCFunction_ClearFreeList` for Python 3.9 and later. [#1425](https://github.com/PyO3/pyo3/pull/1425)
|
||||
- `PYO3_CROSS_LIB_DIR` enviroment variable no long required when compiling for x86-64 Python from macOS arm64 and reverse. [#1428](https://github.com/PyO3/pyo3/pull/1428)
|
||||
- Fix FFI definition `_PyEval_RequestCodeExtraIndex` which took an argument of the wrong type. [#1429](https://github.com/PyO3/pyo3/pull/1429)
|
||||
- Fix FFI definition `PyIter_Check` missing for Python 3.7 and earlier with the `abi3` feature. [#1436](https://github.com/PyO3/pyo3/pull/1436)
|
||||
- Fix FFI definition `PyIndex_Check` missing with the `abi3` feature. [#1436](https://github.com/PyO3/pyo3/pull/1436)
|
||||
|
||||
## [0.13.2] - 2021-02-12
|
||||
|
|
|
@ -89,7 +89,10 @@ extern "C" {
|
|||
pub fn PyObject_GetIter(arg1: *mut PyObject) -> *mut PyObject;
|
||||
}
|
||||
|
||||
#[cfg(not(any(all(Py_3_8, Py_LIMITED_API), PyPy)))]
|
||||
// Defined as this macro in Python 3.6, 3.7 limited API, but relies on
|
||||
// non-limited PyTypeObject. Don't expose this since it cannot be used.
|
||||
#[cfg(not(any(Py_LIMITED_API, PyPy)))]
|
||||
#[inline]
|
||||
pub unsafe fn PyIter_Check(o: *mut PyObject) -> c_int {
|
||||
(match (*crate::ffi::Py_TYPE(o)).tp_iternext {
|
||||
Some(tp_iternext) => {
|
||||
|
@ -150,7 +153,9 @@ extern "C" {
|
|||
pub fn PyNumber_Or(o1: *mut PyObject, o2: *mut PyObject) -> *mut PyObject;
|
||||
}
|
||||
|
||||
#[cfg(not(any(all(Py_3_8, Py_LIMITED_API), PyPy)))]
|
||||
// Defined as this macro in Python 3.6, 3.7 limited API, but relies on
|
||||
// non-limited PyTypeObject. Don't expose this since it cannot be used.
|
||||
#[cfg(not(any(Py_LIMITED_API, PyPy)))]
|
||||
#[inline]
|
||||
pub unsafe fn PyIndex_Check(o: *mut PyObject) -> c_int {
|
||||
let tp_as_number = (*Py_TYPE(o)).tp_as_number;
|
||||
|
|
|
@ -67,6 +67,8 @@ impl<'p> Iterator for &'p PyIterator {
|
|||
}
|
||||
}
|
||||
|
||||
// PyIter_Check does not exist in the limited API until 3.8
|
||||
#[cfg(any(not(Py_LIMITED_API), Py_3_8))]
|
||||
impl<'v> PyTryFrom<'v> for PyIterator {
|
||||
fn try_from<V: Into<&'v PyAny>>(value: V) -> Result<&'v PyIterator, PyDowncastError<'v>> {
|
||||
let value = value.into();
|
||||
|
|
Loading…
Reference in New Issue