Improve Python 3.11 support - #3694
Conversation
|
|
||
| // test_mi_static_properties | ||
| py::class_<Vanilla>(m, "Vanilla").def(py::init<>()).def("vanilla", &Vanilla::vanilla); | ||
| py::class_<Vanilla>(m, "Vanilla", py::dynamic_attr()) |
There was a problem hiding this comment.
Making all bases in the hierarchy either static or dynamic_attrs works, but is not a tenable solution.
…test-311-frame-changes
| + std::to_string(lineno) | ||
| + "): " + handle(f_code->co_name).cast<std::string>() + "\n"; | ||
| frame = frame->f_back; | ||
| # if PY_VERSION_HEX >= 0x030900B1 |
There was a problem hiding this comment.
Nit: Maybe we should add a backport section details/common.h . I just wasn't sure if the recommend static inline stuff would cause any nasty ODR / LTO issues so I left it as is.
|
This fixes compiling scipy with py311. |
|
I looked a bit but have questions for my understanding: Is it true that
It would be useful to explain in a couple sentences in the PR description. |
|
@rwgk This fixes 3.11 compatability. The issue is the new API returns a strong reference (instead of a weak reference) which means we need to decref it. The easiest way to handle this was to have the old code path make a strong reference too. I'll edit the PR description. |
rwgk
left a comment
There was a problem hiding this comment.
The changes LGTM, too, but I'm wondering about
- @Skylion007 I didn't see edits to the PR description, would be nice to have them.
- the valgrind error looks like it needs attention
- is it OK to ignore the upstream failure?
|
Thanks for pointing out that issue @henryiii. Looks good to me now. |
|
I'll run some quick interactive tests in with the Google toolchain. |
* Test out Python 3.11 migration * Clean up a bit * Remove todo * Test workaround * Fix potential bug uncovered in 3.11 * Try to fix it more * last ditch fix * Revert. Tp-traverse isn't the problem * Test workaround * Try this hack * Revert MRO changes * Use f_back properly * Qualify auto * Update include/pybind11/pybind11.h * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Simplify code slightly * Ensure co_varnames decref if dict_getitem throws * Eager decref f_code Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Test out Python 3.11 migration * Clean up a bit * Remove todo * Test workaround * Fix potential bug uncovered in 3.11 * Try to fix it more * last ditch fix * Revert. Tp-traverse isn't the problem * Test workaround * Try this hack * Revert MRO changes * Use f_back properly * Qualify auto * Update include/pybind11/pybind11.h * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Simplify code slightly * Ensure co_varnames decref if dict_getitem throws * Eager decref f_code Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Backport of pybind#3694

Description
Suggested changelog entry: