Skip to content

Commit

Permalink
pypy: even more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Dec 20, 2020
1 parent a0588aa commit 4e07323
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 19 deletions.
9 changes: 5 additions & 4 deletions src/ffi/cpython/abstract_.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::ffi::{PyObject, Py_TYPE, Py_buffer, Py_ssize_t};
use crate::ffi::{PyObject, Py_buffer, Py_ssize_t};
use libc::{c_char, c_int, c_void};

#[cfg(all(Py_3_8, not(PyPy)))]
Expand Down Expand Up @@ -51,7 +51,7 @@ pub unsafe fn PyVectorcall_NARGS(n: size_t) -> Py_ssize_t {
#[inline(always)]
pub unsafe fn PyVectorcall_Function(callable: *mut PyObject) -> Option<vectorcallfunc> {
assert!(!callable.is_null());
let tp = Py_TYPE(callable);
let tp = crate::ffi::Py_TYPE(callable);
if PyType_HasFeature(tp, Py_TPFLAGS_HAVE_VECTORCALL) == 0 {
return None;
}
Expand Down Expand Up @@ -218,7 +218,7 @@ extern "C" {
#[cfg(not(any(Py_3_9, PyPy)))]
#[inline]
pub unsafe fn PyObject_CheckBuffer(o: *mut PyObject) -> c_int {
let tp_as_buffer = (*Py_TYPE(o)).tp_as_buffer;
let tp_as_buffer = (*crate::ffi::Py_TYPE(o)).tp_as_buffer;
(!tp_as_buffer.is_null() && (*tp_as_buffer).bf_getbuffer.is_some()) as c_int
}

Expand Down Expand Up @@ -267,8 +267,9 @@ extern "C" {
}

#[inline]
#[cfg(not(any(all(Py_3_8, Py_LIMITED_API), PyPy)))]
pub unsafe fn PyIter_Check(o: *mut PyObject) -> c_int {
(match (*Py_TYPE(o)).tp_iternext {
(match (*crate::ffi::Py_TYPE(o)).tp_iternext {
Some(tp_iternext) => {
tp_iternext as *const c_void != crate::ffi::object::_PyObject_NextNotImplemented as _
}
Expand Down
13 changes: 0 additions & 13 deletions src/ffi/object.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::ffi::pyport::{Py_hash_t, Py_ssize_t};
#[cfg(PyPy)]
use std::ffi::CStr;
use std::mem;
use std::os::raw::{c_char, c_int, c_uint, c_ulong, c_void};
use std::ptr;
Expand Down Expand Up @@ -75,17 +73,6 @@ pub unsafe fn Py_REFCNT(ob: *mut PyObject) -> Py_ssize_t {
(*ob).ob_refcnt
}

#[cfg(PyPy)]
pub unsafe fn _PyObject_NextNotImplemented(arg1: *mut PyObject) -> *mut PyObject {
return crate::ffi::pyerrors::PyErr_Format(
crate::ffi::pyerrors::PyExc_TypeError,
CStr::from_bytes_with_nul(b"'%.200s' object is not iterable\0")
.unwrap()
.as_ptr(),
Py_TYPE((*(arg1 as *mut PyTypeObject)).tp_name as *mut PyObject),
);
}

#[inline]
pub unsafe fn Py_TYPE(ob: *mut PyObject) -> *mut PyTypeObject {
(*ob).ob_type
Expand Down
2 changes: 1 addition & 1 deletion src/ffi/objectabstract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ extern "C" {
pub fn PyObject_GetIter(arg1: *mut PyObject) -> *mut PyObject;

// PyIter_Check for unlimited API is in cpython/abstract_.rs
#[cfg(all(Py_LIMITED_API, Py_3_8))]
#[cfg(any(all(Py_LIMITED_API, Py_3_8), PyPy))]
#[cfg_attr(PyPy, link_name = "PyPyIter_Check")]
pub fn PyIter_Check(obj: *mut PyObject) -> c_int;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ffi/pythonrun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ extern "C" {
}

#[inline]
#[cfg(not(Py_LIMITED_API))]
#[cfg(any(not(Py_LIMITED_API), PyPy))]
pub unsafe fn Py_CompileString(string: *const c_char, p: *const c_char, s: c_int) -> *mut PyObject {
#[cfg(not(PyPy))]
return Py_CompileStringExFlags(string, p, s, ptr::null_mut(), -1);
Expand Down

0 comments on commit 4e07323

Please sign in to comment.