fix errors in PR

This commit is contained in:
Nicholas Sim 2020-12-28 21:18:27 +08:00
parent 6c3a241dd4
commit aadb58621c
5 changed files with 11 additions and 4 deletions

View File

@ -8,7 +8,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]
### Changed
- Deprecate FFI definitions `PyEval_CallObjectWithKeywords`, `PyEval_CallObject`, `PyEval_CallFunction`, `PyEval_CallMethod` when building for Python 3.9. [#1338](https://github.com/PyO3/pyo3/pull/1338)
- Deprecate FFI definition `PyGetSetDef_DICT` and `PyGetSetDef_INIT` which have never been in the Python API. [#1341](https://github.com/PyO3/pyo3/pull/1341)
- Deprecate FFI definitions `PyGetSetDef_DICT` and `PyGetSetDef_INIT` which have never been in the Python API. [#1341](https://github.com/PyO3/pyo3/pull/1341)
### Removed
- Remove FFI definition `PyFrame_ClearFreeList` when building for Python 3.9. [#1341](https://github.com/PyO3/pyo3/pull/1341)
- Remove FFI definition `_PyDict_Contains` when building for Python 3.10. [#1341](https://github.com/PyO3/pyo3/pull/1341)
### Fixed
- Stop including `Py_TRACE_REFS` config setting automatically if `Py_DEBUG` is set on Python 3.8 and up. [#1334](https://github.com/PyO3/pyo3/pull/1334)

View File

@ -58,6 +58,6 @@ extern "C" {
// skipped _PyDictViewObject
// skipped _PyDictView_New
// skipped _PyDictView_Intersect
// FIXME: PyDict_Contains is defined in dictobject.c
#[cfg(not(Py_3_10))]
pub fn _PyDict_Contains(mp: *mut PyObject, key: *mut PyObject, hash: Py_ssize_t) -> c_int;
}

View File

@ -83,6 +83,6 @@ extern "C" {
// skipped _PyFrame_DebugMallocStats
// skipped PyFrame_GetBack
// FIXME: PyFrame_ClearFreeList is defined in frameobject.c
#[cfg(not(Py_3_9))]
pub fn PyFrame_ClearFreeList() -> c_int;
}

View File

@ -82,6 +82,7 @@ pub const PyGetSetDef_INIT: PyGetSetDef = PyGetSetDef {
#[cfg(any(PyPy, Py_LIMITED_API))]
#[deprecated(note = "not present in Python headers; to be removed")]
#[allow(deprecated)]
pub const PyGetSetDef_DICT: PyGetSetDef = PyGetSetDef_INIT;
/// Helper initial value of [`PyGetSetDef`] for a dict-like Python class.

View File

@ -333,7 +333,6 @@ fn py_class_method_defs<T: PyMethods>() -> (
(new, call, defs)
}
#[allow(deprecated)]
fn py_class_properties<T: PyClass>() -> Vec<ffi::PyGetSetDef> {
let mut defs = std::collections::HashMap::new();
@ -341,6 +340,7 @@ fn py_class_properties<T: PyClass>() -> Vec<ffi::PyGetSetDef> {
match def {
PyMethodDefType::Getter(getter) => {
if !defs.contains_key(getter.name) {
#[allow(deprecated)]
let _ = defs.insert(getter.name.to_owned(), ffi::PyGetSetDef_INIT);
}
let def = defs.get_mut(getter.name).expect("Failed to call get_mut");
@ -348,6 +348,7 @@ fn py_class_properties<T: PyClass>() -> Vec<ffi::PyGetSetDef> {
}
PyMethodDefType::Setter(setter) => {
if !defs.contains_key(setter.name) {
#[allow(deprecated)]
let _ = defs.insert(setter.name.to_owned(), ffi::PyGetSetDef_INIT);
}
let def = defs.get_mut(setter.name).expect("Failed to call get_mut");
@ -363,6 +364,7 @@ fn py_class_properties<T: PyClass>() -> Vec<ffi::PyGetSetDef> {
props.push(ffi::PyGetSetDef_DICT);
}
if !props.is_empty() {
#[allow(deprecated)]
props.push(ffi::PyGetSetDef_INIT);
}
props