Skip to content

Commit 3fe688b

Browse files
committed
graalpy: skip tuple macros
1 parent 742980f commit 3fe688b

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

pyo3-ffi/src/cpython/tupleobject.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ pub unsafe fn PyTuple_GET_SIZE(op: *mut PyObject) -> Py_ssize_t {
2222
}
2323

2424
#[inline]
25-
#[cfg(not(PyPy))]
25+
#[cfg(not(any(PyPy, GraalPy)))]
2626
pub unsafe fn PyTuple_GET_ITEM(op: *mut PyObject, i: Py_ssize_t) -> *mut PyObject {
2727
*(*(op as *mut PyTupleObject)).ob_item.as_ptr().offset(i)
2828
}
2929

3030
/// Macro, *only* to be used to fill in brand new tuples
3131
#[inline]
32-
#[cfg(not(PyPy))]
32+
#[cfg(not(any(PyPy, GraalPy)))]
3333
pub unsafe fn PyTuple_SET_ITEM(op: *mut PyObject, i: Py_ssize_t, v: *mut PyObject) {
3434
*(*(op as *mut PyTupleObject)).ob_item.as_mut_ptr().offset(i) = v;
3535
}

pyo3-ffi/src/structseq.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ extern "C" {
4242
#[cfg(not(Py_LIMITED_API))]
4343
pub type PyStructSequence = crate::PyTupleObject;
4444

45-
#[cfg(not(any(Py_LIMITED_API, PyPy)))]
45+
#[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))]
4646
#[inline]
4747
pub unsafe fn PyStructSequence_SET_ITEM(op: *mut PyObject, i: Py_ssize_t, v: *mut PyObject) {
4848
crate::PyTuple_SET_ITEM(op, i, v)
4949
}
5050

51-
#[cfg(not(any(Py_LIMITED_API, PyPy)))]
51+
#[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))]
5252
#[inline]
5353
pub unsafe fn PyStructSequence_GET_ITEM(op: *mut PyObject, i: Py_ssize_t) -> *mut PyObject {
5454
crate::PyTuple_GET_ITEM(op, i)

src/types/tuple.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ fn new_from_iter(
3333
let mut counter: Py_ssize_t = 0;
3434

3535
for obj in elements.take(len as usize) {
36-
#[cfg(not(any(Py_LIMITED_API, PyPy)))]
36+
#[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))]
3737
ffi::PyTuple_SET_ITEM(ptr, counter, obj.into_ptr());
38-
#[cfg(any(Py_LIMITED_API, PyPy))]
38+
#[cfg(any(Py_LIMITED_API, PyPy, GraalPy))]
3939
ffi::PyTuple_SetItem(ptr, counter, obj.into_ptr());
4040
counter += 1;
4141
}
@@ -164,7 +164,7 @@ impl PyTuple {
164164
/// # Safety
165165
///
166166
/// Caller must verify that the index is within the bounds of the tuple.
167-
#[cfg(not(any(Py_LIMITED_API, PyPy)))]
167+
#[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))]
168168
pub unsafe fn get_item_unchecked(&self, index: usize) -> &PyAny {
169169
let item = ffi::PyTuple_GET_ITEM(self.as_ptr(), index as Py_ssize_t);
170170
self.py().from_borrowed_ptr(item)
@@ -238,9 +238,9 @@ impl<'a> Iterator for PyTupleIterator<'a> {
238238
#[inline]
239239
fn next(&mut self) -> Option<&'a PyAny> {
240240
if self.index < self.length {
241-
#[cfg(any(Py_LIMITED_API, PyPy))]
241+
#[cfg(any(Py_LIMITED_API, PyPy, GraalPy))]
242242
let item = self.tuple.get_item(self.index).expect("tuple.get failed");
243-
#[cfg(not(any(Py_LIMITED_API, PyPy)))]
243+
#[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))]
244244
let item = unsafe { self.tuple.get_item_unchecked(self.index) };
245245
self.index += 1;
246246
Some(item)
@@ -329,10 +329,10 @@ fn type_output() -> TypeInfo {
329329
{
330330
let t: &PyTuple = obj.downcast()?;
331331
if t.len() == $length {
332-
#[cfg(any(Py_LIMITED_API, PyPy))]
332+
#[cfg(any(Py_LIMITED_API, PyPy, GraalPy))]
333333
return Ok(($(t.get_item($n)?.extract::<$T>()?,)+));
334334

335-
#[cfg(not(any(Py_LIMITED_API, PyPy)))]
335+
#[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))]
336336
unsafe {return Ok(($(t.get_item_unchecked($n).extract::<$T>()?,)+));}
337337
} else {
338338
Err(wrong_tuple_length(t, $length))
@@ -630,7 +630,7 @@ mod tests {
630630
});
631631
}
632632

633-
#[cfg(not(any(Py_LIMITED_API, PyPy)))]
633+
#[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))]
634634
#[test]
635635
fn test_tuple_get_item_unchecked_sanity() {
636636
Python::with_gil(|py| {

0 commit comments

Comments
 (0)