mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-27 08:26:05 +00:00
Merge branch 'master' into smart_holder
This commit is contained in:
@@ -172,7 +172,8 @@ public:
|
||||
return false;
|
||||
} else {
|
||||
handle src_or_index = src;
|
||||
#if PY_VERSION_HEX < 0x03080000
|
||||
// PyPy: 7.3.7's 3.8 does not implement PyLong_*'s __index__ calls.
|
||||
#if PY_VERSION_HEX < 0x03080000 || defined(PYPY_VERSION)
|
||||
object index;
|
||||
if (!PYBIND11_LONG_CHECK(src.ptr())) { // So: index_check(src.ptr())
|
||||
index = reinterpret_steal<object>(PyNumber_Index(src.ptr()));
|
||||
|
||||
@@ -19,11 +19,11 @@ PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
||||
PYBIND11_NAMESPACE_BEGIN(detail)
|
||||
|
||||
inline void ensure_builtins_in_globals(object &global) {
|
||||
#if PY_VERSION_HEX < 0x03080000
|
||||
#if defined(PYPY_VERSION) || PY_VERSION_HEX < 0x03080000
|
||||
// Running exec and eval on Python 2 and 3 adds `builtins` module under
|
||||
// `__builtins__` key to globals if not yet present.
|
||||
// Python 3.8 made PyRun_String behave similarly. Let's also do that for
|
||||
// older versions, for consistency.
|
||||
// older versions, for consistency. This was missing from PyPy3.8 7.3.7.
|
||||
if (!global.contains("__builtins__"))
|
||||
global["__builtins__"] = module_::import(PYBIND11_BUILTINS_MODULE);
|
||||
#else
|
||||
|
||||
@@ -2479,8 +2479,9 @@ inline function get_type_override(const void *this_ptr, const type_info *this_ty
|
||||
|
||||
/* Don't call dispatch code if invoked from overridden function.
|
||||
Unfortunately this doesn't work on PyPy. */
|
||||
#if !defined(PYPY_VERSION)
|
||||
|
||||
#if !defined(PYPY_VERSION) && PY_VERSION_HEX < 0x030B0000
|
||||
// TODO: Remove PyPy workaround for Python 3.11.
|
||||
// Current API fails on 3.11 since co_varnames can be null.
|
||||
#if PY_VERSION_HEX >= 0x03090000
|
||||
PyFrameObject *frame = PyThreadState_GetFrame(PyThreadState_Get());
|
||||
if (frame != nullptr) {
|
||||
@@ -2488,7 +2489,7 @@ inline function get_type_override(const void *this_ptr, const type_info *this_ty
|
||||
// f_code is guaranteed to not be NULL
|
||||
if ((std::string) str(f_code->co_name) == name && f_code->co_argcount > 0) {
|
||||
PyObject* locals = PyEval_GetLocals();
|
||||
if (locals != nullptr) {
|
||||
if (locals != nullptr && f_code->co_varnames != nullptr) {
|
||||
PyObject *self_caller = dict_getitem(
|
||||
locals, PyTuple_GET_ITEM(f_code->co_varnames, 0)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user