mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-21 20:55:11 +00:00
fix: Use PyObject_VisitManagedDict() of Python 3.13 (#4973)
* fix: Use PyObject_VisitManagedDict() of Python 3.13 Use PyObject_VisitManagedDict() and PyObject_ClearManagedDict() in pybind11_traverse() and pybind11_clear() on Python 3.13 and newer. * Add Python 3.13 CI * tests: don't get numpy/scipy on 3.13 yet * ci: move 3.13 to upstream Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
This commit is contained in:
parent
daea1130b4
commit
dc477fac0e
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
@ -75,7 +75,6 @@ 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 _
|
||||||
|
8
.github/workflows/upstream.yml
vendored
8
.github/workflows/upstream.yml
vendored
@ -13,13 +13,12 @@ concurrency:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
PIP_BREAK_SYSTEM_PACKAGES: 1
|
PIP_BREAK_SYSTEM_PACKAGES: 1
|
||||||
PIP_ONLY_BINARY: ":all:"
|
|
||||||
# For cmake:
|
# For cmake:
|
||||||
VERBOSE: 1
|
VERBOSE: 1
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
standard:
|
standard:
|
||||||
name: "🐍 3.12 latest • ubuntu-latest • x64"
|
name: "🐍 3.13 latest • ubuntu-latest • x64"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# Only runs when the 'python dev' label is selected
|
# Only runs when the 'python dev' label is selected
|
||||||
if: "contains(github.event.pull_request.labels.*.name, 'python dev')"
|
if: "contains(github.event.pull_request.labels.*.name, 'python dev')"
|
||||||
@ -27,10 +26,11 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Python 3.12
|
- name: Setup Python 3.13
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: "3.12-dev"
|
python-version: "3.13"
|
||||||
|
allow-prereleases: true
|
||||||
|
|
||||||
- name: Setup Boost
|
- name: Setup Boost
|
||||||
run: sudo apt-get install libboost-dev
|
run: sudo apt-get install libboost-dev
|
||||||
|
@ -519,8 +519,12 @@ inline PyObject *make_object_base_type(PyTypeObject *metaclass) {
|
|||||||
|
|
||||||
/// dynamic_attr: Allow the garbage collector to traverse the internal instance `__dict__`.
|
/// dynamic_attr: Allow the garbage collector to traverse the internal instance `__dict__`.
|
||||||
extern "C" inline int pybind11_traverse(PyObject *self, visitproc visit, void *arg) {
|
extern "C" inline int pybind11_traverse(PyObject *self, visitproc visit, void *arg) {
|
||||||
|
#if PY_VERSION_HEX >= 0x030D0000
|
||||||
|
PyObject_VisitManagedDict(self, visit, arg);
|
||||||
|
#else
|
||||||
PyObject *&dict = *_PyObject_GetDictPtr(self);
|
PyObject *&dict = *_PyObject_GetDictPtr(self);
|
||||||
Py_VISIT(dict);
|
Py_VISIT(dict);
|
||||||
|
#endif
|
||||||
// https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_traverse
|
// https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_traverse
|
||||||
#if PY_VERSION_HEX >= 0x03090000
|
#if PY_VERSION_HEX >= 0x03090000
|
||||||
Py_VISIT(Py_TYPE(self));
|
Py_VISIT(Py_TYPE(self));
|
||||||
@ -530,8 +534,12 @@ extern "C" inline int pybind11_traverse(PyObject *self, visitproc visit, void *a
|
|||||||
|
|
||||||
/// dynamic_attr: Allow the GC to clear the dictionary.
|
/// dynamic_attr: Allow the GC to clear the dictionary.
|
||||||
extern "C" inline int pybind11_clear(PyObject *self) {
|
extern "C" inline int pybind11_clear(PyObject *self) {
|
||||||
|
#if PY_VERSION_HEX >= 0x030D0000
|
||||||
|
PyObject_ClearManagedDict(self);
|
||||||
|
#else
|
||||||
PyObject *&dict = *_PyObject_GetDictPtr(self);
|
PyObject *&dict = *_PyObject_GetDictPtr(self);
|
||||||
Py_CLEAR(dict);
|
Py_CLEAR(dict);
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@ numpy~=1.25.0; python_version=="3.9" and platform_python_implementation=='PyPy'
|
|||||||
numpy~=1.19.3; platform_python_implementation!="PyPy" and python_version=="3.6"
|
numpy~=1.19.3; platform_python_implementation!="PyPy" and python_version=="3.6"
|
||||||
numpy~=1.21.5; platform_python_implementation!="PyPy" and python_version>="3.7" and python_version<"3.10"
|
numpy~=1.21.5; platform_python_implementation!="PyPy" and python_version>="3.7" and python_version<"3.10"
|
||||||
numpy~=1.22.2; platform_python_implementation!="PyPy" and python_version=="3.10"
|
numpy~=1.22.2; platform_python_implementation!="PyPy" and python_version=="3.10"
|
||||||
numpy~=1.26.0; platform_python_implementation!="PyPy" and python_version>="3.11"
|
numpy~=1.26.0; platform_python_implementation!="PyPy" and python_version>="3.11" and python_version<"3.13"
|
||||||
pytest~=7.0
|
pytest~=7.0
|
||||||
pytest-timeout
|
pytest-timeout
|
||||||
scipy~=1.5.4; platform_python_implementation!="PyPy" and python_version<"3.10"
|
scipy~=1.5.4; platform_python_implementation!="PyPy" and python_version<"3.10"
|
||||||
scipy~=1.8.0; platform_python_implementation!="PyPy" and python_version=="3.10"
|
scipy~=1.8.0; platform_python_implementation!="PyPy" and python_version=="3.10"
|
||||||
scipy~=1.11.1; platform_python_implementation!="PyPy" and python_version>="3.11"
|
scipy~=1.11.1; platform_python_implementation!="PyPy" and python_version>="3.11" and python_version<"3.13"
|
||||||
|
Loading…
Reference in New Issue
Block a user