diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b481112f0..eb6ee3bad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,9 +34,8 @@ jobs: python: - '3.6' - '3.9' - - '3.10' - - '3.11' - '3.12' + - '3.13' - 'pypy-3.8' - 'pypy-3.9' - 'pypy-3.10' @@ -64,6 +63,10 @@ jobs: # Inject a couple Windows 2019 runs - runs-on: windows-2019 python: '3.9' + # Extra ubuntu latest job + - runs-on: ubuntu-latest + python: '3.11' + name: "🐍 ${{ matrix.python }} • ${{ matrix.runs-on }} • x64 ${{ matrix.args }}" runs-on: ${{ matrix.runs-on }} @@ -75,6 +78,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} + allow-prereleases: true - name: Setup Boost (Linux) # Can't use boost + define _ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 260ee04df..c9ea41758 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,14 +25,14 @@ repos: # Clang format the codebase automatically - repo: https://github.com/pre-commit/mirrors-clang-format - rev: "v18.1.4" + rev: "v18.1.5" hooks: - id: clang-format types_or: [c++, c, cuda] # Ruff, the Python auto-correcting linter/formatter written in Rust - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.3 + rev: v0.4.5 hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -78,7 +78,7 @@ repos: - id: trailing-whitespace # Also code format the docs -- repo: https://github.com/asottile/blacken-docs +- repo: https://github.com/adamchainz/blacken-docs rev: "1.16.0" hooks: - id: blacken-docs @@ -119,7 +119,7 @@ repos: # Use tools/codespell_ignore_lines_from_errors.py # to rebuild .codespell-ignore-lines - repo: https://github.com/codespell-project/codespell - rev: "v2.2.6" + rev: "v2.3.0" hooks: - id: codespell exclude: ".supp$" @@ -142,13 +142,14 @@ repos: # PyLint has native support - not always usable, but works for us - repo: https://github.com/PyCQA/pylint - rev: "v3.1.0" + rev: "v3.2.2" hooks: - id: pylint files: ^pybind11 +# Check schemas on some of our YAML files - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.28.2 + rev: 0.28.4 hooks: - id: check-readthedocs - id: check-github-workflows diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 429d2138d..1b890615e 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -1344,8 +1344,14 @@ using module = module_; /// 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). inline dict globals() { +#if PY_VERSION_HEX >= 0x030d0000 + PyObject *p = PyEval_GetFrameGlobals(); + return p ? reinterpret_steal(p) + : reinterpret_borrow(module_::import("__main__").attr("__dict__").ptr()); +#else PyObject *p = PyEval_GetGlobals(); return reinterpret_borrow(p ? p : module_::import("__main__").attr("__dict__").ptr()); +#endif } template ()>> @@ -2770,7 +2776,12 @@ get_type_override(const void *this_ptr, const type_info *this_type, const char * PyCodeObject *f_code = PyFrame_GetCode(frame); // f_code is guaranteed to not be NULL 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(); + Py_INCREF(locals); +# endif if (locals != nullptr) { # if PY_VERSION_HEX >= 0x030b0000 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); Py_DECREF(co_varnames); PyObject *self_caller = dict_getitem(locals, self_arg); + Py_DECREF(locals); if (self_caller == self.ptr()) { Py_DECREF(f_code); Py_DECREF(frame); diff --git a/pyproject.toml b/pyproject.toml index da02caa87..1f011c2f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,6 @@ ignore = [ files = ["pybind11"] python_version = "3.8" strict = true -show_error_codes = true enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] warn_unreachable = true @@ -30,18 +29,6 @@ module = ["ghapi.*"] ignore_missing_imports = true -[tool.pytest.ini_options] -minversion = "6.0" -addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"] -xfail_strict = true -filterwarnings = ["error"] -log_cli_level = "info" -testpaths = [ - "tests", -] -timeout=300 - - [tool.pylint] master.py-version = "3.6" reports.output-format = "colorized" @@ -93,3 +80,6 @@ isort.known-first-party = ["env", "pybind11_cross_module_tests", "pybind11_tests [tool.ruff.lint.per-file-ignores] "tests/**" = ["EM", "N", "E721"] "tests/test_call_policies.py" = ["PLC1901"] + +[tool.repo-review] +ignore = ["PP"] diff --git a/tests/pytest.ini b/tests/pytest.ini index 792ba361f..42c3c40c6 100644 --- a/tests/pytest.ini +++ b/tests/pytest.ini @@ -20,3 +20,4 @@ filterwarnings = # bogus numpy ABI warning (see numpy/#432) ignore:.*numpy.dtype size changed.*:RuntimeWarning ignore:.*numpy.ufunc size changed.*:RuntimeWarning + default:The global interpreter lock:RuntimeWarning