mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 06:35:12 +00:00
fix: support Python 3.13.0b1 (PEP 667 fix) (#5127)
* ci: add Python 3.13
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* tests: run the gc for 3.13+
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* Revert "tests: run the gc for 3.13+"
This reverts commit fe8a3ce3d1
.
* ci: drop macos ARM for now, need pin updates
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* fix: use Python 3.13 API if on 3.13
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
---------
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
This commit is contained in:
parent
b07fddb219
commit
4d0fcedc26
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
@ -34,9 +34,8 @@ jobs:
|
|||||||
python:
|
python:
|
||||||
- '3.6'
|
- '3.6'
|
||||||
- '3.9'
|
- '3.9'
|
||||||
- '3.10'
|
|
||||||
- '3.11'
|
|
||||||
- '3.12'
|
- '3.12'
|
||||||
|
- '3.13'
|
||||||
- 'pypy-3.8'
|
- 'pypy-3.8'
|
||||||
- 'pypy-3.9'
|
- 'pypy-3.9'
|
||||||
- 'pypy-3.10'
|
- 'pypy-3.10'
|
||||||
@ -64,6 +63,10 @@ jobs:
|
|||||||
# Inject a couple Windows 2019 runs
|
# Inject a couple Windows 2019 runs
|
||||||
- runs-on: windows-2019
|
- runs-on: windows-2019
|
||||||
python: '3.9'
|
python: '3.9'
|
||||||
|
# Extra ubuntu latest job
|
||||||
|
- runs-on: ubuntu-latest
|
||||||
|
python: '3.11'
|
||||||
|
|
||||||
|
|
||||||
name: "🐍 ${{ matrix.python }} • ${{ matrix.runs-on }} • x64 ${{ matrix.args }}"
|
name: "🐍 ${{ matrix.python }} • ${{ matrix.runs-on }} • x64 ${{ matrix.args }}"
|
||||||
runs-on: ${{ matrix.runs-on }}
|
runs-on: ${{ matrix.runs-on }}
|
||||||
@ -75,6 +78,7 @@ jobs:
|
|||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python }}
|
python-version: ${{ matrix.python }}
|
||||||
|
allow-prereleases: true
|
||||||
|
|
||||||
- name: Setup Boost (Linux)
|
- name: Setup Boost (Linux)
|
||||||
# Can't use boost + define _
|
# Can't use boost + define _
|
||||||
|
@ -1344,8 +1344,14 @@ using module = module_;
|
|||||||
/// Return a dictionary representing the global variables in the current execution frame,
|
/// Return a dictionary representing the global variables in the current execution frame,
|
||||||
/// or ``__main__.__dict__`` if there is no frame (usually when the interpreter is embedded).
|
/// or ``__main__.__dict__`` if there is no frame (usually when the interpreter is embedded).
|
||||||
inline dict globals() {
|
inline dict globals() {
|
||||||
|
#if PY_VERSION_HEX >= 0x030d0000
|
||||||
|
PyObject *p = PyEval_GetFrameGlobals();
|
||||||
|
return p ? reinterpret_steal<dict>(p)
|
||||||
|
: reinterpret_borrow<dict>(module_::import("__main__").attr("__dict__").ptr());
|
||||||
|
#else
|
||||||
PyObject *p = PyEval_GetGlobals();
|
PyObject *p = PyEval_GetGlobals();
|
||||||
return reinterpret_borrow<dict>(p ? p : module_::import("__main__").attr("__dict__").ptr());
|
return reinterpret_borrow<dict>(p ? p : module_::import("__main__").attr("__dict__").ptr());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Args, typename = detail::enable_if_t<args_are_all_keyword_or_ds<Args...>()>>
|
template <typename... Args, typename = detail::enable_if_t<args_are_all_keyword_or_ds<Args...>()>>
|
||||||
@ -2770,7 +2776,12 @@ get_type_override(const void *this_ptr, const type_info *this_type, const char *
|
|||||||
PyCodeObject *f_code = PyFrame_GetCode(frame);
|
PyCodeObject *f_code = PyFrame_GetCode(frame);
|
||||||
// f_code is guaranteed to not be NULL
|
// f_code is guaranteed to not be NULL
|
||||||
if ((std::string) str(f_code->co_name) == name && f_code->co_argcount > 0) {
|
if ((std::string) str(f_code->co_name) == name && f_code->co_argcount > 0) {
|
||||||
|
# if PY_VERSION_HEX >= 0x030d0000
|
||||||
|
PyObject *locals = PyEval_GetFrameLocals();
|
||||||
|
# else
|
||||||
PyObject *locals = PyEval_GetLocals();
|
PyObject *locals = PyEval_GetLocals();
|
||||||
|
Py_INCREF(locals);
|
||||||
|
# endif
|
||||||
if (locals != nullptr) {
|
if (locals != nullptr) {
|
||||||
# if PY_VERSION_HEX >= 0x030b0000
|
# if PY_VERSION_HEX >= 0x030b0000
|
||||||
PyObject *co_varnames = PyCode_GetVarnames(f_code);
|
PyObject *co_varnames = PyCode_GetVarnames(f_code);
|
||||||
@ -2780,6 +2791,7 @@ get_type_override(const void *this_ptr, const type_info *this_type, const char *
|
|||||||
PyObject *self_arg = PyTuple_GET_ITEM(co_varnames, 0);
|
PyObject *self_arg = PyTuple_GET_ITEM(co_varnames, 0);
|
||||||
Py_DECREF(co_varnames);
|
Py_DECREF(co_varnames);
|
||||||
PyObject *self_caller = dict_getitem(locals, self_arg);
|
PyObject *self_caller = dict_getitem(locals, self_arg);
|
||||||
|
Py_DECREF(locals);
|
||||||
if (self_caller == self.ptr()) {
|
if (self_caller == self.ptr()) {
|
||||||
Py_DECREF(f_code);
|
Py_DECREF(f_code);
|
||||||
Py_DECREF(frame);
|
Py_DECREF(frame);
|
||||||
|
Loading…
Reference in New Issue
Block a user