Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pypy: even more fixes #1331

Merged
merged 1 commit into from
Dec 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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