We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9ce9544 commit bf0afd9Copy full SHA for bf0afd9
pyo3-ffi/src/cpython/bytesobject.rs
@@ -1,6 +1,6 @@
1
use crate::object::*;
2
use crate::Py_ssize_t;
3
-#[cfg(not(any(PyPy, GraalPy, Py_LIMITED_API)))]
+#[cfg(not(any(PyPy, Py_LIMITED_API)))]
4
use std::os::raw::c_char;
5
use std::os::raw::c_int;
6
@@ -23,3 +23,11 @@ extern "C" {
23
#[cfg_attr(PyPy, link_name = "_PyPyBytes_Resize")]
24
pub fn _PyBytes_Resize(bytes: *mut *mut PyObject, newsize: Py_ssize_t) -> c_int;
25
}
26
+
27
+#[inline]
28
+pub unsafe fn PyBytes_AS_STRING(op: *mut PyObject) -> *const c_char {
29
+ #[cfg(not(any(PyPy, GraalPy, Py_LIMITED_API)))]
30
+ return &(*op.cast::<PyBytesObject>()).ob_sval as *const c_char;
31
+ #[cfg(any(PyPy, GraalPy, Py_LIMITED_API))]
32
+ return crate::PyBytes_AsString(op);
33
+}
0 commit comments