Remove doc_cfg attributes

This commit is contained in:
mejrs 2021-10-17 15:47:09 +02:00
parent 7087ee1183
commit 20c3c068f8
32 changed files with 5 additions and 66 deletions

View File

@ -1,5 +1,4 @@
#![cfg(not(Py_LIMITED_API))]
#![cfg_attr(docsrs, doc(cfg(not(Py_LIMITED_API))))]
// Copyright (c) 2017 Daniel Grunwald
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this

View File

@ -7,7 +7,6 @@ mod macros;
pub mod basic;
#[cfg(not(Py_LIMITED_API))]
#[cfg_attr(docsrs, doc(cfg(not(Py_LIMITED_API))))]
pub mod buffer;
pub mod context;
pub mod descr;
@ -24,7 +23,6 @@ pub mod sequence;
pub use self::basic::PyObjectProtocol;
#[cfg(not(Py_LIMITED_API))]
#[cfg_attr(docsrs, doc(cfg(not(Py_LIMITED_API))))]
pub use self::buffer::PyBufferProtocol;
pub use self::context::PyContextProtocol;
pub use self::descr::PyDescrProtocol;

View File

@ -1,5 +1,5 @@
#![cfg(feature = "eyre")]
#![cfg_attr(docsrs, doc(cfg(feature = "eyre")))]
//! A conversion from [eyre]s [`Report`] type to [`PyErr`].
//!
//! Use of an error handling library like [eyre] is common in application code and when you just

View File

@ -1,5 +1,4 @@
#![cfg(feature = "hashbrown")]
#![cfg_attr(docsrs, doc(cfg(feature = "hashbrown")))]
//! Conversions to and from [hashbrown](https://docs.rs/hashbrown/)s
//! `HashMap` and `HashSet`.

View File

@ -1,5 +1,4 @@
#![cfg(feature = "indexmap")]
#![cfg_attr(docsrs, doc(cfg(feature = "indexmap")))]
//! Conversions to and from [indexmap](https://docs.rs/indexmap/)s
//! `IndexMap`.

View File

@ -3,11 +3,6 @@
// based on Daniel Grunwald's https://github.com/dgrunwald/rust-cpython
#![cfg(all(feature = "num-bigint", not(any(Py_LIMITED_API, PyPy))))]
#![cfg_attr(
docsrs,
doc(cfg(all(feature = "num-bigint", not(any(Py_LIMITED_API, PyPy)))))
)]
//! Conversions to and from [num-bigint](https://docs.rs/num-bigint)s [`BigInt`] and [`BigUint`] types.
//!
//! This is useful for converting Python integers when they may not fit in Rust's built-in integer types.

View File

@ -1,5 +1,5 @@
#![cfg(feature = "num-complex")]
#![cfg_attr(docsrs, doc(cfg(feature = "num-complex")))]
//! Conversions to and from [num-complex](https://docs.rs/num-complex)
//! [`Complex`]`<`[`f32`]`>` and [`Complex`]`<`[`f64`]`>`.
//!

View File

@ -1,4 +1,3 @@
#![cfg_attr(docsrs, doc(cfg(feature = "serde")))]
#![cfg(feature = "serde")]
//! Enables (de)serialization of [`Py`]`<T>` objects via [serde](https://docs.rs/serde).

View File

@ -113,7 +113,6 @@ extern "C" {
#[cfg_attr(PyPy, link_name = "PyPyIter_Next")]
pub fn PyIter_Next(arg1: *mut PyObject) -> *mut PyObject;
#[cfg(all(not(PyPy), Py_3_10))]
#[cfg_attr(docsrs, doc(cfg(all(not(PyPy), Py_3_10))))]
pub fn PyIter_Send(iter: *mut PyObject, arg: *mut PyObject, presult: *mut *mut PyObject);
#[cfg_attr(PyPy, link_name = "PyPyNumber_Check")]

View File

@ -43,17 +43,14 @@ extern "C" {
// skipped _PyThread_CurrentExceptions
#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
pub fn PyInterpreterState_Main() -> *mut PyInterpreterState;
#[cfg_attr(PyPy, link_name = "PyPyInterpreterState_Head")]
pub fn PyInterpreterState_Head() -> *mut PyInterpreterState;
#[cfg_attr(PyPy, link_name = "PyPyInterpreterState_Next")]
pub fn PyInterpreterState_Next(interp: *mut PyInterpreterState) -> *mut PyInterpreterState;
#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
pub fn PyInterpreterState_ThreadHead(interp: *mut PyInterpreterState) -> *mut PyThreadState;
#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
pub fn PyThreadState_Next(tstate: *mut PyThreadState) -> *mut PyThreadState;
#[cfg(py_sys_config = "WITH_THREAD")]
@ -62,7 +59,6 @@ extern "C" {
}
#[cfg(Py_3_9)]
#[cfg_attr(docsrs, doc(cfg(Py_3_9)))]
pub type _PyFrameEvalFunction = extern "C" fn(
*mut crate::ffi::PyThreadState,
*mut crate::ffi::PyFrameObject,
@ -72,13 +68,11 @@ pub type _PyFrameEvalFunction = extern "C" fn(
#[cfg(Py_3_9)]
extern "C" {
/// Get the frame evaluation function.
#[cfg_attr(docsrs, doc(cfg(Py_3_9)))]
pub fn _PyInterpreterState_GetEvalFrameFunc(
interp: *mut PyInterpreterState,
) -> _PyFrameEvalFunction;
///Set the frame evaluation function.
#[cfg_attr(docsrs, doc(cfg(Py_3_9)))]
pub fn _PyInterpreterState_SetEvalFrameFunc(
interp: *mut PyInterpreterState,
eval_frame: _PyFrameEvalFunction,

View File

@ -252,7 +252,6 @@ extern "C" {
// skipped _PyUnicode_Copy
#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
pub fn PyUnicode_CopyCharacters(
to: *mut PyObject,
to_start: Py_ssize_t,
@ -264,7 +263,6 @@ extern "C" {
// skipped _PyUnicode_FastCopyCharacters
#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
pub fn PyUnicode_Fill(
unicode: *mut PyObject,
start: Py_ssize_t,

View File

@ -54,7 +54,6 @@ extern "C" {
// skipped non-limited _PyArg_Fini
#[cfg(Py_3_10)]
#[cfg_attr(docsrs, doc(cfg(Py_3_10)))]
pub fn PyModule_AddObjectRef(
module: *mut PyObject,
name: *const c_char,

View File

@ -353,11 +353,9 @@ extern "C" {
pub const Py_PRINT_RAW: c_int = 1; // No string quotes etc.
#[cfg(Py_3_10)]
#[cfg_attr(docsrs, doc(cfg(Py_3_10)))]
pub const Py_TPFLAGS_DISALLOW_INSTANTIATION: c_ulong = 1 << 7;
#[cfg(Py_3_10)]
#[cfg_attr(docsrs, doc(cfg(Py_3_10)))]
pub const Py_TPFLAGS_IMMUTABLETYPE: c_ulong = 1 << 8;
/// Set if the type object is dynamically allocated
@ -468,10 +466,8 @@ extern "C" {
pub fn Py_DecRef(o: *mut PyObject);
#[cfg(Py_3_10)]
#[cfg_attr(docsrs, doc(cfg(Py_3_10)))]
pub fn Py_NewRef(obj: *mut PyObject) -> *mut PyObject;
#[cfg(Py_3_10)]
#[cfg_attr(docsrs, doc(cfg(Py_3_10)))]
pub fn Py_XNewRef(obj: *mut PyObject) -> *mut PyObject;
}

View File

@ -30,11 +30,10 @@ extern "C" {
pub fn PyGC_Collect() -> Py_ssize_t;
#[cfg(Py_3_10)]
#[cfg_attr(docsrs, doc(cfg(Py_3_10)))]
pub fn PyGC_Enable() -> c_int;
#[cfg_attr(docsrs, doc(cfg(Py_3_10)))]
pub fn PyGC_Disable() -> c_int;
#[cfg_attr(docsrs, doc(cfg(Py_3_10)))]
pub fn PyGC_IsEnabled() -> c_int;
}

View File

@ -375,7 +375,6 @@ extern "C" {
#[cfg_attr(PyPy, link_name = "PyPyErr_SetInterrupt")]
pub fn PyErr_SetInterrupt();
#[cfg(Py_3_10)]
#[cfg_attr(docsrs, doc(cfg(Py_3_10)))]
pub fn PyErr_SetInterruptEx(signum: c_int);
pub fn PyErr_SyntaxLocation(filename: *const c_char, lineno: c_int);
pub fn PyErr_SyntaxLocationEx(filename: *const c_char, lineno: c_int, col_offset: c_int);

View File

@ -13,37 +13,28 @@ opaque_struct!(PyInterpreterState);
extern "C" {
#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
pub fn PyInterpreterState_New() -> *mut PyInterpreterState;
#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
pub fn PyInterpreterState_Clear(arg1: *mut PyInterpreterState);
#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
pub fn PyInterpreterState_Delete(arg1: *mut PyInterpreterState);
#[cfg(all(Py_3_9, not(PyPy)))]
#[cfg_attr(docsrs, doc(cfg(all(Py_3_9, not(PyPy)))))]
pub fn PyInterpreterState_Get() -> *mut PyInterpreterState;
#[cfg(all(Py_3_8, not(PyPy)))]
#[cfg_attr(docsrs, doc(cfg(all(Py_3_8, not(PyPy)))))]
pub fn PyInterpreterState_GetDict(arg1: *mut PyInterpreterState) -> *mut PyObject;
#[cfg(all(Py_3_7, not(PyPy)))]
#[cfg_attr(docsrs, doc(cfg(all(Py_3_7, not(PyPy)))))]
pub fn PyInterpreterState_GetID(arg1: *mut PyInterpreterState) -> i64;
#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
pub fn PyState_AddModule(arg1: *mut PyObject, arg2: *mut PyModuleDef) -> c_int;
#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
pub fn PyState_RemoveModule(arg1: *mut PyModuleDef) -> c_int;
#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
pub fn PyState_FindModule(arg1: *mut PyModuleDef) -> *mut PyObject;
#[cfg_attr(PyPy, link_name = "PyPyThreadState_New")]
@ -68,7 +59,6 @@ extern "C" {
#[cfg_attr(PyPy, link_name = "PyPyThreadState_GetDict")]
pub fn PyThreadState_GetDict() -> *mut PyObject;
#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
pub fn PyThreadState_SetAsyncExc(arg1: c_long, arg2: *mut PyObject) -> c_int;
}
@ -89,6 +79,5 @@ extern "C" {
#[cfg_attr(PyPy, link_name = "PyPyGILState_Release")]
pub fn PyGILState_Release(arg1: PyGILState_STATE);
#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
pub fn PyGILState_GetThisThreadState() -> *mut PyThreadState;
}

View File

@ -119,7 +119,6 @@ pub unsafe fn PyAnySet_Check(ob: *mut PyObject) -> c_int {
#[inline]
#[cfg(Py_3_10)]
#[cfg_attr(docsrs, doc(cfg(Py_3_10)))]
pub unsafe fn PySet_CheckExact(op: *mut PyObject) -> c_int {
crate::ffi::Py_IS_TYPE(op, &mut PySet_Type)
}

View File

@ -34,7 +34,6 @@ extern "C" {
) -> c_int;
#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
pub fn PyStructSequence_NewType(desc: *mut PyStructSequence_Desc) -> *mut PyTypeObject;
#[cfg_attr(PyPy, link_name = "PyPyStructSequence_New")]
pub fn PyStructSequence_New(_type: *mut PyTypeObject) -> *mut PyObject;
@ -57,10 +56,8 @@ pub unsafe fn PyStructSequence_GET_ITEM(op: *mut PyObject, i: Py_ssize_t) -> *mu
extern "C" {
#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
pub fn PyStructSequence_SetItem(arg1: *mut PyObject, arg2: Py_ssize_t, arg3: *mut PyObject);
#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
pub fn PyStructSequence_GetItem(arg1: *mut PyObject, arg2: Py_ssize_t) -> *mut PyObject;
}

View File

@ -166,11 +166,9 @@ extern "C" {
#[cfg_attr(PyPy, link_name = "PyPyUnicode_AsUTF8String")]
pub fn PyUnicode_AsUTF8String(unicode: *mut PyObject) -> *mut PyObject;
#[cfg(any(Py_3_10, all(Py_3_7, not(Py_LIMITED_API))))]
#[cfg_attr(docsrs, doc(cfg(any(Py_3_10, not(Py_LIMITED_API)))))]
#[cfg_attr(PyPy, link_name = "PyPyUnicode_AsUTF8AndSize")]
pub fn PyUnicode_AsUTF8AndSize(unicode: *mut PyObject, size: *mut Py_ssize_t) -> *const c_char;
#[cfg(not(any(Py_3_7, Py_LIMITED_API)))]
#[cfg_attr(docsrs, doc(cfg(any(Py_3_10, not(Py_LIMITED_API)))))]
#[cfg_attr(PyPy, link_name = "PyPyUnicode_AsUTF8AndSize")]
pub fn PyUnicode_AsUTF8AndSize(unicode: *mut PyObject, size: *mut Py_ssize_t) -> *mut c_char;
#[cfg_attr(PyPy, link_name = "PyPyUnicode_DecodeUTF32")]

View File

@ -69,7 +69,6 @@ pub(crate) fn gil_is_acquired() -> bool {
/// # }
/// ```
#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
#[allow(clippy::collapsible_if)] // for if cfg!
pub fn prepare_freethreaded_python() {
// Protect against race conditions when Python is not yet initialized and multiple threads
@ -135,7 +134,6 @@ pub fn prepare_freethreaded_python() {
/// # }
/// ```
#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
#[allow(clippy::collapsible_if)] // for if cfg!
pub unsafe fn with_embedded_python_interpreter<F, R>(f: F) -> R
where

View File

@ -285,7 +285,6 @@ pub use crate::conversion::{
};
pub use crate::err::{PyDowncastError, PyErr, PyErrArguments, PyResult};
#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
pub use crate::gil::{prepare_freethreaded_python, with_embedded_python_interpreter};
pub use crate::gil::{GILGuard, GILPool};
pub use crate::instance::{Py, PyNativeType, PyObject};
@ -351,7 +350,6 @@ pub mod proc_macro {
pub use pyo3_macros::{pyclass, pyfunction, pymethods, pymodule, pyproto};
}
#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
#[cfg(feature = "macros")]
pub use pyo3_macros::{pyclass, pyfunction, pymethods, pymodule, pyproto, FromPyObject};

View File

@ -1,5 +1,5 @@
#![cfg(not(Py_LIMITED_API))]
#![cfg_attr(docsrs, doc(cfg(not(Py_LIMITED_API))))]
//! Support for the Python `marshal` format.
use crate::ffi;

View File

@ -22,6 +22,5 @@ pub use crate::python::Python;
pub use crate::types::{PyAny, PyModule};
pub use crate::wrap_pyfunction;
#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
#[cfg(feature = "macros")]
pub use pyo3_macros::{pyclass, pyfunction, pymethods, pymodule, pyproto, FromPyObject};

View File

@ -37,7 +37,6 @@ impl PyComplex {
}
#[cfg(not(any(Py_LIMITED_API, PyPy)))]
#[cfg_attr(docsrs, doc(cfg(not(any(Py_LIMITED_API, PyPy)))))]
mod not_limited_impls {
use super::*;
use std::ops::{Add, Div, Mul, Neg, Sub};

View File

@ -39,7 +39,6 @@ impl PyDict {
/// Returns an error on invalid input. In the case of key collisions,
/// this keeps the last entry seen.
#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
pub fn from_sequence(py: Python, seq: PyObject) -> PyResult<&PyDict> {
unsafe {
let dict = py.from_owned_ptr::<PyDict>(ffi::PyDict_New());

View File

@ -71,7 +71,6 @@ 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))]
#[cfg_attr(docsrs, doc(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();

View File

@ -98,7 +98,6 @@ impl PyList {
///
/// Caller must verify that the index is within the bounds of the list.
#[cfg(not(any(Py_LIMITED_API, PyPy)))]
#[cfg_attr(docsrs, doc(cfg(not(any(Py_LIMITED_API, PyPy)))))]
pub unsafe fn get_item_unchecked(&self, index: usize) -> &PyAny {
let item = ffi::PyList_GET_ITEM(self.as_ptr(), index as Py_ssize_t);
// PyList_GET_ITEM return borrowed ptr; must make owned for safety (see #890).

View File

@ -8,7 +8,6 @@ pub use self::bytearray::PyByteArray;
pub use self::bytes::PyBytes;
pub use self::complex::PyComplex;
#[cfg(not(Py_LIMITED_API))]
#[cfg_attr(docsrs, doc(cfg(not(Py_LIMITED_API))))]
pub use self::datetime::{
PyDate, PyDateAccess, PyDateTime, PyDelta, PyDeltaAccess, PyTime, PyTimeAccess, PyTzInfo,
};
@ -225,7 +224,6 @@ mod bytearray;
mod bytes;
mod complex;
#[cfg(not(Py_LIMITED_API))]
#[cfg_attr(docsrs, doc(cfg(not(Py_LIMITED_API))))]
mod datetime;
mod dict;
mod floatob;

View File

@ -176,7 +176,6 @@ impl PyModule {
///
/// May fail if the module does not have a `__file__` attribute.
#[cfg(not(all(windows, PyPy)))]
#[cfg_attr(docsrs, doc(cfg(not(all(windows, PyPy)))))]
pub fn filename(&self) -> PyResult<&str> {
use crate::types::PyString;
unsafe {

View File

@ -183,7 +183,6 @@ impl PySequence {
/// number of keys for which `self[key] == value`.
#[inline]
#[cfg(not(PyPy))]
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
pub fn count<V>(&self, value: V) -> PyResult<usize>
where
V: ToBorrowedObject,

View File

@ -16,7 +16,6 @@ use std::str;
/// Python internally stores strings in various representations. This enumeration
/// represents those variations.
#[cfg(not(any(Py_LIMITED_API, target_endian = "big")))]
#[cfg_attr(docsrs, doc(cfg(not(any(Py_LIMITED_API, target_endian = "big")))))]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum PyStringData<'a> {
/// UCS1 representation.
@ -225,7 +224,6 @@ impl PyString {
///
/// For example, it is known not to work on big-endian platforms.
#[cfg(not(any(Py_LIMITED_API, target_endian = "big")))]
#[cfg_attr(docsrs, doc(cfg(not(any(Py_LIMITED_API, target_endian = "big")))))]
pub unsafe fn data(&self) -> PyResult<PyStringData<'_>> {
let ptr = self.as_ptr();

View File

@ -134,7 +134,6 @@ impl PyTuple {
///
/// Caller must verify that the index is within the bounds of the tuple.
#[cfg(not(any(Py_LIMITED_API, PyPy)))]
#[cfg_attr(docsrs, doc(cfg(not(any(Py_LIMITED_API, PyPy)))))]
pub unsafe fn get_item_unchecked(&self, index: usize) -> &PyAny {
let item = ffi::PyTuple_GET_ITEM(self.as_ptr(), index as Py_ssize_t);
self.py().from_borrowed_ptr(item)
@ -142,7 +141,6 @@ impl PyTuple {
/// Returns `self` as a slice of objects.
#[cfg(not(Py_LIMITED_API))]
#[cfg_attr(docsrs, doc(cfg(not(Py_LIMITED_API))))]
pub fn as_slice(&self) -> &[&PyAny] {
// This is safe because &PyAny has the same memory layout as *mut ffi::PyObject,
// and because tuples are immutable.