mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-29 00:22:00 +00:00
Merge branch 'v2.10' into stable
This commit is contained in:
commit
be97c5a98b
11
.github/workflows/ci.yml
vendored
11
.github/workflows/ci.yml
vendored
@ -280,6 +280,8 @@ jobs:
|
|||||||
- dev
|
- dev
|
||||||
std:
|
std:
|
||||||
- 11
|
- 11
|
||||||
|
container_suffix:
|
||||||
|
- ""
|
||||||
include:
|
include:
|
||||||
- clang: 5
|
- clang: 5
|
||||||
std: 14
|
std: 14
|
||||||
@ -293,9 +295,12 @@ jobs:
|
|||||||
std: 20
|
std: 20
|
||||||
- clang: 14
|
- clang: 14
|
||||||
std: 20
|
std: 20
|
||||||
|
- clang: 15
|
||||||
|
std: 20
|
||||||
|
container_suffix: "-bullseye"
|
||||||
|
|
||||||
name: "🐍 3 • Clang ${{ matrix.clang }} • C++${{ matrix.std }} • x64"
|
name: "🐍 3 • Clang ${{ matrix.clang }} • C++${{ matrix.std }} • x64"
|
||||||
container: "silkeh/clang:${{ matrix.clang }}"
|
container: "silkeh/clang:${{ matrix.clang }}${{ matrix.container_suffix }}"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@ -761,7 +766,7 @@ jobs:
|
|||||||
uses: jwlawson/actions-setup-cmake@v1.13
|
uses: jwlawson/actions-setup-cmake@v1.13
|
||||||
|
|
||||||
- name: Prepare MSVC
|
- name: Prepare MSVC
|
||||||
uses: ilammy/msvc-dev-cmd@v1.12.0
|
uses: ilammy/msvc-dev-cmd@v1.12.1
|
||||||
with:
|
with:
|
||||||
arch: x86
|
arch: x86
|
||||||
|
|
||||||
@ -814,7 +819,7 @@ jobs:
|
|||||||
uses: jwlawson/actions-setup-cmake@v1.13
|
uses: jwlawson/actions-setup-cmake@v1.13
|
||||||
|
|
||||||
- name: Prepare MSVC
|
- name: Prepare MSVC
|
||||||
uses: ilammy/msvc-dev-cmd@v1.12.0
|
uses: ilammy/msvc-dev-cmd@v1.12.1
|
||||||
with:
|
with:
|
||||||
arch: x86
|
arch: x86
|
||||||
|
|
||||||
|
8
.github/workflows/pip.yml
vendored
8
.github/workflows/pip.yml
vendored
@ -98,13 +98,13 @@ jobs:
|
|||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
|
|
||||||
- name: Publish standard package
|
- name: Publish standard package
|
||||||
uses: pypa/gh-action-pypi-publish@v1.6.4
|
uses: pypa/gh-action-pypi-publish@v1.8.1
|
||||||
with:
|
with:
|
||||||
password: ${{ secrets.pypi_password }}
|
password: ${{ secrets.pypi_password }}
|
||||||
packages_dir: standard/
|
packages-dir: standard/
|
||||||
|
|
||||||
- name: Publish global package
|
- name: Publish global package
|
||||||
uses: pypa/gh-action-pypi-publish@v1.6.4
|
uses: pypa/gh-action-pypi-publish@v1.8.1
|
||||||
with:
|
with:
|
||||||
password: ${{ secrets.pypi_password_global }}
|
password: ${{ secrets.pypi_password_global }}
|
||||||
packages_dir: global/
|
packages-dir: global/
|
||||||
|
@ -48,46 +48,46 @@ repos:
|
|||||||
|
|
||||||
# Nicely sort includes
|
# Nicely sort includes
|
||||||
- repo: https://github.com/PyCQA/isort
|
- repo: https://github.com/PyCQA/isort
|
||||||
rev: "5.11.4"
|
rev: "5.12.0"
|
||||||
hooks:
|
hooks:
|
||||||
- id: isort
|
- id: isort
|
||||||
|
|
||||||
# Black, the code formatter, natively supports pre-commit
|
# Black, the code formatter, natively supports pre-commit
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: "22.12.0" # Keep in sync with blacken-docs
|
rev: "23.1.0" # Keep in sync with blacken-docs
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
|
|
||||||
# Also code format the docs
|
# Also code format the docs
|
||||||
- repo: https://github.com/asottile/blacken-docs
|
- repo: https://github.com/asottile/blacken-docs
|
||||||
rev: "v1.12.1"
|
rev: "1.13.0"
|
||||||
hooks:
|
hooks:
|
||||||
- id: blacken-docs
|
- id: blacken-docs
|
||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
- black==22.10.0 # keep in sync with black hook
|
- black==23.1.0 # keep in sync with black hook
|
||||||
|
|
||||||
# Changes tabs to spaces
|
# Changes tabs to spaces
|
||||||
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
||||||
rev: "v1.3.1"
|
rev: "v1.4.2"
|
||||||
hooks:
|
hooks:
|
||||||
- id: remove-tabs
|
- id: remove-tabs
|
||||||
|
|
||||||
- repo: https://github.com/sirosen/texthooks
|
- repo: https://github.com/sirosen/texthooks
|
||||||
rev: "0.4.0"
|
rev: "0.5.0"
|
||||||
hooks:
|
hooks:
|
||||||
- id: fix-ligatures
|
- id: fix-ligatures
|
||||||
- id: fix-smartquotes
|
- id: fix-smartquotes
|
||||||
|
|
||||||
# Autoremoves unused imports
|
# Autoremoves unused imports
|
||||||
- repo: https://github.com/hadialqattan/pycln
|
- repo: https://github.com/hadialqattan/pycln
|
||||||
rev: "v2.1.2"
|
rev: "v2.1.3"
|
||||||
hooks:
|
hooks:
|
||||||
- id: pycln
|
- id: pycln
|
||||||
stages: [manual]
|
stages: [manual]
|
||||||
|
|
||||||
# Checking for common mistakes
|
# Checking for common mistakes
|
||||||
- repo: https://github.com/pre-commit/pygrep-hooks
|
- repo: https://github.com/pre-commit/pygrep-hooks
|
||||||
rev: "v1.9.0"
|
rev: "v1.10.0"
|
||||||
hooks:
|
hooks:
|
||||||
- id: python-check-blanket-noqa
|
- id: python-check-blanket-noqa
|
||||||
- id: python-check-blanket-type-ignore
|
- id: python-check-blanket-type-ignore
|
||||||
@ -116,7 +116,7 @@ repos:
|
|||||||
|
|
||||||
# PyLint has native support - not always usable, but works for us
|
# PyLint has native support - not always usable, but works for us
|
||||||
- repo: https://github.com/PyCQA/pylint
|
- repo: https://github.com/PyCQA/pylint
|
||||||
rev: "v2.15.9"
|
rev: "v2.16.1"
|
||||||
hooks:
|
hooks:
|
||||||
- id: pylint
|
- id: pylint
|
||||||
files: ^pybind11
|
files: ^pybind11
|
||||||
@ -175,7 +175,7 @@ repos:
|
|||||||
|
|
||||||
# Clang format the codebase automatically
|
# Clang format the codebase automatically
|
||||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||||
rev: "v15.0.6"
|
rev: "v15.0.7"
|
||||||
hooks:
|
hooks:
|
||||||
- id: clang-format
|
- id: clang-format
|
||||||
types_or: [c++, c, cuda]
|
types_or: [c++, c, cuda]
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
prune tests
|
||||||
recursive-include pybind11/include/pybind11 *.h
|
recursive-include pybind11/include/pybind11 *.h
|
||||||
recursive-include pybind11 *.py
|
recursive-include pybind11 *.py
|
||||||
recursive-include pybind11 py.typed
|
recursive-include pybind11 py.typed
|
||||||
|
@ -21,11 +21,47 @@ Changes:
|
|||||||
``dec_ref()`` are now enabled by default again.
|
``dec_ref()`` are now enabled by default again.
|
||||||
`#4246 <https://github.com/pybind/pybind11/pull/4246>`_
|
`#4246 <https://github.com/pybind/pybind11/pull/4246>`_
|
||||||
|
|
||||||
|
* ``py::initialize_interpreter()`` using ``PyConfig_InitPythonConfig()``
|
||||||
|
instead of ``PyConfig_InitIsolatedConfig()``, to obtain complete
|
||||||
|
``sys.path``.
|
||||||
|
`#4473 <https://github.com/pybind/pybind11/pull/4473>`_
|
||||||
|
|
||||||
|
* Cast errors now always include Python type information, even if
|
||||||
|
``PYBIND11_DETAILED_ERROR_MESSAGES`` is not defined. This increases binary
|
||||||
|
sizes slightly (~1.5%) but the error messages are much more informative.
|
||||||
|
`#4463 <https://github.com/pybind/pybind11/pull/4463>`_
|
||||||
|
|
||||||
|
|
||||||
Build system improvements:
|
Build system improvements:
|
||||||
|
|
||||||
* Update clang-tidy to 15 in CI.
|
* Update clang-tidy to 15 in CI.
|
||||||
`#4387 <https://github.com/pybind/pybind11/pull/4387>`_
|
`#4387 <https://github.com/pybind/pybind11/pull/4387>`_
|
||||||
|
|
||||||
|
* Moved the linting framework over to Ruff.
|
||||||
|
`#4483 <https://github.com/pybind/pybind11/pull/4483>`_
|
||||||
|
|
||||||
|
Version 2.10.4 (Mar 16, 2023)
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
* ``python3 -m pybind11`` gained a ``--version`` option (prints the version and
|
||||||
|
exits).
|
||||||
|
`#4526 <https://github.com/pybind/pybind11/pull/4526>`_
|
||||||
|
|
||||||
|
Bug Fixes:
|
||||||
|
|
||||||
|
* Fix a warning when pydebug is enabled on Python 3.11.
|
||||||
|
`#4461 <https://github.com/pybind/pybind11/pull/4461>`_
|
||||||
|
|
||||||
|
* Ensure ``gil_scoped_release`` RAII is non-copyable.
|
||||||
|
`#4490 <https://github.com/pybind/pybind11/pull/4490>`_
|
||||||
|
|
||||||
|
* Ensure the tests dir does not show up with new versions of setuptools.
|
||||||
|
`#4510 <https://github.com/pybind/pybind11/pull/4510>`_
|
||||||
|
|
||||||
|
* Better stacklevel for a warning in setuptools helpers.
|
||||||
|
`#4516 <https://github.com/pybind/pybind11/pull/4516>`_
|
||||||
|
|
||||||
Version 2.10.3 (Jan 3, 2023)
|
Version 2.10.3 (Jan 3, 2023)
|
||||||
----------------------------
|
----------------------------
|
||||||
|
@ -358,7 +358,6 @@ def clean_up(app, exception):
|
|||||||
|
|
||||||
|
|
||||||
def setup(app):
|
def setup(app):
|
||||||
|
|
||||||
# Add hook for building doxygen xml when needed
|
# Add hook for building doxygen xml when needed
|
||||||
app.connect("builder-inited", generate_doxygen_xml)
|
app.connect("builder-inited", generate_doxygen_xml)
|
||||||
|
|
||||||
|
@ -445,9 +445,17 @@ inline void clear_instance(PyObject *self) {
|
|||||||
/// Instance destructor function for all pybind11 types. It calls `type_info.dealloc`
|
/// Instance destructor function for all pybind11 types. It calls `type_info.dealloc`
|
||||||
/// to destroy the C++ object itself, while the rest is Python bookkeeping.
|
/// to destroy the C++ object itself, while the rest is Python bookkeeping.
|
||||||
extern "C" inline void pybind11_object_dealloc(PyObject *self) {
|
extern "C" inline void pybind11_object_dealloc(PyObject *self) {
|
||||||
|
auto *type = Py_TYPE(self);
|
||||||
|
|
||||||
|
// If this is a GC tracked object, untrack it first
|
||||||
|
// Note that the track call is implicitly done by the
|
||||||
|
// default tp_alloc, which we never override.
|
||||||
|
if (PyType_HasFeature(type, Py_TPFLAGS_HAVE_GC) != 0) {
|
||||||
|
PyObject_GC_UnTrack(self);
|
||||||
|
}
|
||||||
|
|
||||||
clear_instance(self);
|
clear_instance(self);
|
||||||
|
|
||||||
auto *type = Py_TYPE(self);
|
|
||||||
type->tp_free(self);
|
type->tp_free(self);
|
||||||
|
|
||||||
#if PY_VERSION_HEX < 0x03080000
|
#if PY_VERSION_HEX < 0x03080000
|
||||||
|
@ -11,11 +11,11 @@
|
|||||||
|
|
||||||
#define PYBIND11_VERSION_MAJOR 2
|
#define PYBIND11_VERSION_MAJOR 2
|
||||||
#define PYBIND11_VERSION_MINOR 10
|
#define PYBIND11_VERSION_MINOR 10
|
||||||
#define PYBIND11_VERSION_PATCH 3
|
#define PYBIND11_VERSION_PATCH 4
|
||||||
|
|
||||||
// Similar to Python's convention: https://docs.python.org/3/c-api/apiabiversion.html
|
// Similar to Python's convention: https://docs.python.org/3/c-api/apiabiversion.html
|
||||||
// Additional convention: 0xD = dev
|
// Additional convention: 0xD = dev
|
||||||
#define PYBIND11_VERSION_HEX 0x020A0300
|
#define PYBIND11_VERSION_HEX 0x020A0400
|
||||||
|
|
||||||
// Define some generic pybind11 helper macros for warning management.
|
// Define some generic pybind11 helper macros for warning management.
|
||||||
//
|
//
|
||||||
@ -437,7 +437,7 @@ PYBIND11_WARNING_POP
|
|||||||
|
|
||||||
/** \rst
|
/** \rst
|
||||||
This macro creates the entry point that will be invoked when the Python interpreter
|
This macro creates the entry point that will be invoked when the Python interpreter
|
||||||
imports an extension module. The module name is given as the fist argument and it
|
imports an extension module. The module name is given as the first argument and it
|
||||||
should not be in quotes. The second macro argument defines a variable of type
|
should not be in quotes. The second macro argument defines a variable of type
|
||||||
`py::module_` which can be used to initialize the module.
|
`py::module_` which can be used to initialize the module.
|
||||||
|
|
||||||
|
@ -19,7 +19,9 @@
|
|||||||
PYBIND11_WARNING_PUSH
|
PYBIND11_WARNING_PUSH
|
||||||
PYBIND11_WARNING_DISABLE_MSVC(5054) // https://github.com/pybind/pybind11/pull/3741
|
PYBIND11_WARNING_DISABLE_MSVC(5054) // https://github.com/pybind/pybind11/pull/3741
|
||||||
// C5054: operator '&': deprecated between enumerations of different types
|
// C5054: operator '&': deprecated between enumerations of different types
|
||||||
|
#if defined(__MINGW32__)
|
||||||
PYBIND11_WARNING_DISABLE_GCC("-Wmaybe-uninitialized")
|
PYBIND11_WARNING_DISABLE_GCC("-Wmaybe-uninitialized")
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <Eigen/Core>
|
#include <Eigen/Core>
|
||||||
#include <Eigen/SparseCore>
|
#include <Eigen/SparseCore>
|
||||||
|
@ -17,7 +17,9 @@ static_assert(__GNUC__ > 5, "Eigen Tensor support in pybind11 requires GCC > 5.0
|
|||||||
PYBIND11_WARNING_PUSH
|
PYBIND11_WARNING_PUSH
|
||||||
PYBIND11_WARNING_DISABLE_MSVC(4554)
|
PYBIND11_WARNING_DISABLE_MSVC(4554)
|
||||||
PYBIND11_WARNING_DISABLE_MSVC(4127)
|
PYBIND11_WARNING_DISABLE_MSVC(4127)
|
||||||
|
#if defined(__MINGW32__)
|
||||||
PYBIND11_WARNING_DISABLE_GCC("-Wmaybe-uninitialized")
|
PYBIND11_WARNING_DISABLE_GCC("-Wmaybe-uninitialized")
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <unsupported/Eigen/CXX11/Tensor>
|
#include <unsupported/Eigen/CXX11/Tensor>
|
||||||
|
|
||||||
|
@ -152,8 +152,8 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gil_scoped_release(const gil_scoped_acquire &) = delete;
|
gil_scoped_release(const gil_scoped_release &) = delete;
|
||||||
gil_scoped_release &operator=(const gil_scoped_acquire &) = delete;
|
gil_scoped_release &operator=(const gil_scoped_release &) = delete;
|
||||||
|
|
||||||
/// This method will disable the PyThreadState_DeleteCurrent call and the
|
/// This method will disable the PyThreadState_DeleteCurrent call and the
|
||||||
/// GIL won't be acquired. This method should be used if the interpreter
|
/// GIL won't be acquired. This method should be used if the interpreter
|
||||||
@ -203,7 +203,7 @@ class gil_scoped_release {
|
|||||||
public:
|
public:
|
||||||
gil_scoped_release() : state{PyEval_SaveThread()} {}
|
gil_scoped_release() : state{PyEval_SaveThread()} {}
|
||||||
gil_scoped_release(const gil_scoped_release &) = delete;
|
gil_scoped_release(const gil_scoped_release &) = delete;
|
||||||
gil_scoped_release &operator=(const gil_scoped_acquire &) = delete;
|
gil_scoped_release &operator=(const gil_scoped_release &) = delete;
|
||||||
~gil_scoped_release() { PyEval_RestoreThread(state); }
|
~gil_scoped_release() { PyEval_RestoreThread(state); }
|
||||||
void disarm() {}
|
void disarm() {}
|
||||||
};
|
};
|
||||||
@ -230,7 +230,7 @@ public:
|
|||||||
(void) (this != (this + 1));
|
(void) (this != (this + 1));
|
||||||
}
|
}
|
||||||
gil_scoped_release(const gil_scoped_release &) = delete;
|
gil_scoped_release(const gil_scoped_release &) = delete;
|
||||||
gil_scoped_release &operator=(const gil_scoped_acquire &) = delete;
|
gil_scoped_release &operator=(const gil_scoped_release &) = delete;
|
||||||
void disarm() {}
|
void disarm() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1121,10 +1121,10 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a proxy object that provides const access to the array's data without bounds or
|
* Returns a proxy object that provides const access to the array's data without bounds or
|
||||||
* dimensionality checking. Unlike `unchecked()`, this does not require that the underlying
|
* dimensionality checking. Unlike `mutable_unchecked()`, this does not require that the
|
||||||
* array have the `writable` flag. Use with care: the array must not be destroyed or reshaped
|
* underlying array have the `writable` flag. Use with care: the array must not be destroyed
|
||||||
* for the duration of the returned object, and the caller must take care not to access invalid
|
* or reshaped for the duration of the returned object, and the caller must take care not to
|
||||||
* dimensions or dimension indices.
|
* access invalid dimensions or dimension indices.
|
||||||
*/
|
*/
|
||||||
template <ssize_t Dims = -1>
|
template <ssize_t Dims = -1>
|
||||||
detail::unchecked_reference<T, Dims> unchecked() const & {
|
detail::unchecked_reference<T, Dims> unchecked() const & {
|
||||||
|
@ -4,6 +4,7 @@ import argparse
|
|||||||
import sys
|
import sys
|
||||||
import sysconfig
|
import sysconfig
|
||||||
|
|
||||||
|
from ._version import __version__
|
||||||
from .commands import get_cmake_dir, get_include, get_pkgconfig_dir
|
from .commands import get_cmake_dir, get_include, get_pkgconfig_dir
|
||||||
|
|
||||||
|
|
||||||
@ -24,8 +25,13 @@ def print_includes() -> None:
|
|||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument(
|
||||||
|
"--version",
|
||||||
|
action="version",
|
||||||
|
version=__version__,
|
||||||
|
help="Print the version and exit.",
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--includes",
|
"--includes",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
|
@ -8,5 +8,5 @@ def _to_int(s: str) -> Union[int, str]:
|
|||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
__version__ = "2.10.3"
|
__version__ = "2.10.4"
|
||||||
version_info = tuple(_to_int(s) for s in __version__.split("."))
|
version_info = tuple(_to_int(s) for s in __version__.split("."))
|
||||||
|
@ -118,7 +118,6 @@ class Pybind11Extension(_Extension): # type: ignore[misc]
|
|||||||
self.extra_link_args[:0] = flags
|
self.extra_link_args[:0] = flags
|
||||||
|
|
||||||
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||||
|
|
||||||
self._cxx_level = 0
|
self._cxx_level = 0
|
||||||
cxx_std = kwargs.pop("cxx_std", 0)
|
cxx_std = kwargs.pop("cxx_std", 0)
|
||||||
|
|
||||||
@ -174,9 +173,10 @@ class Pybind11Extension(_Extension): # type: ignore[misc]
|
|||||||
|
|
||||||
@cxx_std.setter
|
@cxx_std.setter
|
||||||
def cxx_std(self, level: int) -> None:
|
def cxx_std(self, level: int) -> None:
|
||||||
|
|
||||||
if self._cxx_level:
|
if self._cxx_level:
|
||||||
warnings.warn("You cannot safely change the cxx_level after setting it!")
|
warnings.warn(
|
||||||
|
"You cannot safely change the cxx_level after setting it!", stacklevel=2
|
||||||
|
)
|
||||||
|
|
||||||
# MSVC 2015 Update 3 and later only have 14 (and later 17) modes, so
|
# MSVC 2015 Update 3 and later only have 14 (and later 17) modes, so
|
||||||
# force a valid flag here.
|
# force a valid flag here.
|
||||||
@ -439,7 +439,6 @@ class ParallelCompile:
|
|||||||
extra_postargs: Optional[List[str]] = None,
|
extra_postargs: Optional[List[str]] = None,
|
||||||
depends: Optional[List[str]] = None,
|
depends: Optional[List[str]] = None,
|
||||||
) -> Any:
|
) -> Any:
|
||||||
|
|
||||||
# These lines are directly from distutils.ccompiler.CCompiler
|
# These lines are directly from distutils.ccompiler.CCompiler
|
||||||
macros, objects, extra_postargs, pp_opts, build = compiler._setup_compile( # type: ignore[attr-defined]
|
macros, objects, extra_postargs, pp_opts, build = compiler._setup_compile( # type: ignore[attr-defined]
|
||||||
output_dir, macros, include_dirs, sources, depends, extra_postargs
|
output_dir, macros, include_dirs, sources, depends, extra_postargs
|
||||||
|
@ -169,7 +169,7 @@ if(PYBIND11_TEST_OVERRIDE)
|
|||||||
# This allows the override to be done with extensions, preserving backwards compatibility.
|
# This allows the override to be done with extensions, preserving backwards compatibility.
|
||||||
foreach(test_name ${TEST_FILES_NO_EXT})
|
foreach(test_name ${TEST_FILES_NO_EXT})
|
||||||
if(NOT ${test_name} IN_LIST TEST_OVERRIDE_NO_EXT
|
if(NOT ${test_name} IN_LIST TEST_OVERRIDE_NO_EXT
|
||||||
)# If not in the whitelist, add to be filtered out.
|
)# If not in the allowlist, add to be filtered out.
|
||||||
list(APPEND PYBIND11_TEST_FILTER ${test_name})
|
list(APPEND PYBIND11_TEST_FILTER ${test_name})
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
@ -11,11 +11,17 @@ import multiprocessing
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import textwrap
|
import textwrap
|
||||||
|
import traceback
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
# Early diagnostic for failed imports
|
# Early diagnostic for failed imports
|
||||||
import pybind11_tests
|
try:
|
||||||
|
import pybind11_tests
|
||||||
|
except Exception:
|
||||||
|
# pytest does not show the traceback without this.
|
||||||
|
traceback.print_exc()
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session", autouse=True)
|
@pytest.fixture(scope="session", autouse=True)
|
||||||
|
@ -135,7 +135,6 @@ def normalize_line_endings(value: bytes) -> bytes:
|
|||||||
|
|
||||||
|
|
||||||
def test_build_sdist(monkeypatch, tmpdir):
|
def test_build_sdist(monkeypatch, tmpdir):
|
||||||
|
|
||||||
monkeypatch.chdir(MAIN_DIR)
|
monkeypatch.chdir(MAIN_DIR)
|
||||||
|
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
@ -186,7 +185,6 @@ def test_build_sdist(monkeypatch, tmpdir):
|
|||||||
|
|
||||||
|
|
||||||
def test_build_global_dist(monkeypatch, tmpdir):
|
def test_build_global_dist(monkeypatch, tmpdir):
|
||||||
|
|
||||||
monkeypatch.chdir(MAIN_DIR)
|
monkeypatch.chdir(MAIN_DIR)
|
||||||
monkeypatch.setenv("PYBIND11_GLOBAL_SDIST", "1")
|
monkeypatch.setenv("PYBIND11_GLOBAL_SDIST", "1")
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
|
@ -7,7 +7,6 @@ from pybind11_tests import chrono as m
|
|||||||
|
|
||||||
|
|
||||||
def test_chrono_system_clock():
|
def test_chrono_system_clock():
|
||||||
|
|
||||||
# Get the time from both c++ and datetime
|
# Get the time from both c++ and datetime
|
||||||
date0 = datetime.datetime.today()
|
date0 = datetime.datetime.today()
|
||||||
date1 = m.test_chrono1()
|
date1 = m.test_chrono1()
|
||||||
@ -122,7 +121,6 @@ def test_chrono_system_clock_roundtrip_time(time1, tz, monkeypatch):
|
|||||||
|
|
||||||
|
|
||||||
def test_chrono_duration_roundtrip():
|
def test_chrono_duration_roundtrip():
|
||||||
|
|
||||||
# Get the difference between two times (a timedelta)
|
# Get the difference between two times (a timedelta)
|
||||||
date1 = datetime.datetime.today()
|
date1 = datetime.datetime.today()
|
||||||
date2 = datetime.datetime.today()
|
date2 = datetime.datetime.today()
|
||||||
@ -143,7 +141,6 @@ def test_chrono_duration_roundtrip():
|
|||||||
|
|
||||||
|
|
||||||
def test_chrono_duration_subtraction_equivalence():
|
def test_chrono_duration_subtraction_equivalence():
|
||||||
|
|
||||||
date1 = datetime.datetime.today()
|
date1 = datetime.datetime.today()
|
||||||
date2 = datetime.datetime.today()
|
date2 = datetime.datetime.today()
|
||||||
|
|
||||||
@ -154,7 +151,6 @@ def test_chrono_duration_subtraction_equivalence():
|
|||||||
|
|
||||||
|
|
||||||
def test_chrono_duration_subtraction_equivalence_date():
|
def test_chrono_duration_subtraction_equivalence_date():
|
||||||
|
|
||||||
date1 = datetime.date.today()
|
date1 = datetime.date.today()
|
||||||
date2 = datetime.date.today()
|
date2 = datetime.date.today()
|
||||||
|
|
||||||
|
@ -185,7 +185,6 @@ def test_inheritance(msg):
|
|||||||
|
|
||||||
|
|
||||||
def test_inheritance_init(msg):
|
def test_inheritance_init(msg):
|
||||||
|
|
||||||
# Single base
|
# Single base
|
||||||
class Python(m.Pet):
|
class Python(m.Pet):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -94,7 +94,8 @@ def test_noconvert_args(msg):
|
|||||||
|
|
||||||
def test_custom_caster_destruction():
|
def test_custom_caster_destruction():
|
||||||
"""Tests that returning a pointer to a type that gets converted with a custom type caster gets
|
"""Tests that returning a pointer to a type that gets converted with a custom type caster gets
|
||||||
destroyed when the function has py::return_value_policy::take_ownership policy applied."""
|
destroyed when the function has py::return_value_policy::take_ownership policy applied.
|
||||||
|
"""
|
||||||
|
|
||||||
cstats = m.destruction_tester_cstats()
|
cstats = m.destruction_tester_cstats()
|
||||||
# This one *doesn't* have take_ownership: the pointer should be used but not destroyed:
|
# This one *doesn't* have take_ownership: the pointer should be used but not destroyed:
|
||||||
|
@ -59,7 +59,6 @@ def assert_equal_tensor_ref(mat, writeable=True, modified=None):
|
|||||||
@pytest.mark.parametrize("m", submodules)
|
@pytest.mark.parametrize("m", submodules)
|
||||||
@pytest.mark.parametrize("member_name", ["member", "member_view"])
|
@pytest.mark.parametrize("member_name", ["member", "member_view"])
|
||||||
def test_reference_internal(m, member_name):
|
def test_reference_internal(m, member_name):
|
||||||
|
|
||||||
if not hasattr(sys, "getrefcount"):
|
if not hasattr(sys, "getrefcount"):
|
||||||
pytest.skip("No reference counting")
|
pytest.skip("No reference counting")
|
||||||
foo = m.CustomExample()
|
foo = m.CustomExample()
|
||||||
@ -108,7 +107,6 @@ def test_convert_tensor_to_py(m, func_name):
|
|||||||
|
|
||||||
@pytest.mark.parametrize("m", submodules)
|
@pytest.mark.parametrize("m", submodules)
|
||||||
def test_bad_cpp_to_python_casts(m):
|
def test_bad_cpp_to_python_casts(m):
|
||||||
|
|
||||||
with pytest.raises(
|
with pytest.raises(
|
||||||
RuntimeError, match="Cannot use reference internal when there is no parent"
|
RuntimeError, match="Cannot use reference internal when there is no parent"
|
||||||
):
|
):
|
||||||
@ -131,7 +129,6 @@ def test_bad_cpp_to_python_casts(m):
|
|||||||
|
|
||||||
@pytest.mark.parametrize("m", submodules)
|
@pytest.mark.parametrize("m", submodules)
|
||||||
def test_bad_python_to_cpp_casts(m):
|
def test_bad_python_to_cpp_casts(m):
|
||||||
|
|
||||||
with pytest.raises(
|
with pytest.raises(
|
||||||
TypeError, match=r"^round_trip_tensor\(\): incompatible function arguments"
|
TypeError, match=r"^round_trip_tensor\(\): incompatible function arguments"
|
||||||
):
|
):
|
||||||
@ -194,7 +191,6 @@ def test_bad_python_to_cpp_casts(m):
|
|||||||
|
|
||||||
@pytest.mark.parametrize("m", submodules)
|
@pytest.mark.parametrize("m", submodules)
|
||||||
def test_references_actually_refer(m):
|
def test_references_actually_refer(m):
|
||||||
|
|
||||||
a = m.reference_tensor()
|
a = m.reference_tensor()
|
||||||
temp = a[indices]
|
temp = a[indices]
|
||||||
a[indices] = 100
|
a[indices] = 100
|
||||||
@ -211,7 +207,6 @@ def test_references_actually_refer(m):
|
|||||||
|
|
||||||
@pytest.mark.parametrize("m", submodules)
|
@pytest.mark.parametrize("m", submodules)
|
||||||
def test_round_trip(m):
|
def test_round_trip(m):
|
||||||
|
|
||||||
assert_equal_tensor_ref(m.round_trip_tensor(tensor_ref))
|
assert_equal_tensor_ref(m.round_trip_tensor(tensor_ref))
|
||||||
|
|
||||||
with pytest.raises(TypeError, match="^Cannot cast array data from"):
|
with pytest.raises(TypeError, match="^Cannot cast array data from"):
|
||||||
@ -260,7 +255,6 @@ def test_round_trip(m):
|
|||||||
|
|
||||||
@pytest.mark.parametrize("m", submodules)
|
@pytest.mark.parametrize("m", submodules)
|
||||||
def test_round_trip_references_actually_refer(m):
|
def test_round_trip_references_actually_refer(m):
|
||||||
|
|
||||||
# Need to create a copy that matches the type on the C side
|
# Need to create a copy that matches the type on the C side
|
||||||
copy = np.array(tensor_ref, dtype=np.float64, order=m.needed_options)
|
copy = np.array(tensor_ref, dtype=np.float64, order=m.needed_options)
|
||||||
a = m.round_trip_view_tensor(copy)
|
a = m.round_trip_view_tensor(copy)
|
||||||
|
@ -130,7 +130,8 @@ def test_stl_bind_global():
|
|||||||
def test_mixed_local_global():
|
def test_mixed_local_global():
|
||||||
"""Local types take precedence over globally registered types: a module with a `module_local`
|
"""Local types take precedence over globally registered types: a module with a `module_local`
|
||||||
type can be registered even if the type is already registered globally. With the module,
|
type can be registered even if the type is already registered globally. With the module,
|
||||||
casting will go to the local type; outside the module casting goes to the global type."""
|
casting will go to the local type; outside the module casting goes to the global type.
|
||||||
|
"""
|
||||||
import pybind11_cross_module_tests as cm
|
import pybind11_cross_module_tests as cm
|
||||||
|
|
||||||
m.register_mixed_global()
|
m.register_mixed_global()
|
||||||
|
@ -107,11 +107,10 @@ def test_def_submodule_failures():
|
|||||||
sm_name_orig = sm.__name__
|
sm_name_orig = sm.__name__
|
||||||
sm.__name__ = malformed_utf8
|
sm.__name__ = malformed_utf8
|
||||||
try:
|
try:
|
||||||
with pytest.raises(Exception):
|
# We want to assert that a bad __name__ causes some kind of failure, although we do not want to exercise
|
||||||
# Seen with Python 3.9: SystemError: nameless module
|
# the internals of PyModule_GetName(). Currently all supported Python versions raise SystemError. If that
|
||||||
# But we do not want to exercise the internals of PyModule_GetName(), which could
|
# changes in future Python versions, simply add the new expected exception types here.
|
||||||
# change in future versions of Python, but a bad __name__ is very likely to cause
|
with pytest.raises(SystemError):
|
||||||
# some kind of failure indefinitely.
|
|
||||||
m.def_submodule(sm, b"SubSubModuleName")
|
m.def_submodule(sm, b"SubSubModuleName")
|
||||||
finally:
|
finally:
|
||||||
# Clean up to ensure nothing gets upset by a module with an invalid __name__.
|
# Clean up to ensure nothing gets upset by a module with an invalid __name__.
|
||||||
|
@ -130,7 +130,6 @@ def test_nested():
|
|||||||
|
|
||||||
|
|
||||||
def test_overriding_eq_reset_hash():
|
def test_overriding_eq_reset_hash():
|
||||||
|
|
||||||
assert m.Comparable(15) is not m.Comparable(15)
|
assert m.Comparable(15) is not m.Comparable(15)
|
||||||
assert m.Comparable(15) == m.Comparable(15)
|
assert m.Comparable(15) == m.Comparable(15)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user