-
Notifications
You must be signed in to change notification settings - Fork 2k
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
fix: support Python 3.13.0b1 (PEP 667 fix) #5127
Conversation
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
This reverts commit fe8a3ce.
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Some destructors are not being called when they used to be. The following three tests break:
In these, Running #/usr/bin/env bash
set -euo pipefail
./configure --prefix $PWD/../python
make -j8
make install -j8
cd ..
uv pip install --python=./Python/bin/python3 pytest
cmake -S. -Bbuild -DPython_ROOT_DIR=Python -DPYBIND11_TEST_OVERRIDE='test_factory_constructors.py;test_virtual_functions.py'
cmake --build build --target pytest Showed this broke with python/cpython#115153, PEP 667. These are now replaced with new functions: $ git grep -E 'PyEval_GetLocals|PyEval_GetGlobals|PyEval_GetBuiltins|\.f_locals'
include/pybind11/detail/internals.h:446: state_dict = reinterpret_borrow<object>(PyEval_GetBuiltins());
include/pybind11/pybind11.h:1347: PyObject *p = PyEval_GetGlobals();
include/pybind11/pybind11.h:2773: PyObject *locals = PyEval_GetLocals();
include/pybind11/pybind11.h:2820: " self_caller = frame.f_locals[frame.f_code.co_varnames[0]]\n"
tests/constructor_stats.h:116: PyObject *globals = PyEval_GetGlobals(); These are now no-ops: $ git grep -E 'PyFrame_FastToLocalsWithError|PyFrame_FastToLocals|git grep PyFrame_LocalsToFast'
include/pybind11/pybind11.h:2797: PyFrame_FastToLocals(frame);
|
0a457ea
to
b5a125a
Compare
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
b5a125a
to
540bef2
Compare
FYI, four tests fail (related to refcounts) when using free-threaded 3.13 but holding the GIL. |
PyObject *locals = PyEval_GetLocals(); | ||
Py_INCREF(locals); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@henryiii This Py_INCREF(locals)
appears before the locals != nullptr
test, therefore I think it could segfault in object.h: op->ob_refcnt++;
. Did you consider that already? Did you mean to use Py_XINCREF(locals)
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I did, thanks! I think it’s very unlikely that this will be null, but best to be correct!
Description
Since beta 1 is out, time to start testing all the time on Python 3.13, not just PR’s with a dev label.
Suggested changelog entry: