pybind11/tests
Daniel Galvez 7c6f2f80a7
fix: PyCapsule_GetDestructor is allowed to return a nullptr destructor (#4221)
* fix: PyCapsule_GetDestructor is allowed to return a nullptr destructor

Previously, this code would error out if the destructor happened to be
a nullptr. This is incorrect. nullptrs are allowed for capsule
destructors.

"It is legal for a capsule to have a NULL destructor. This makes a
NULL return code somewhat ambiguous; use PyCapsule_IsValid() or
PyErr_Occurred() to disambiguate."

See:

https://docs.python.org/3/c-api/capsule.html#c.PyCapsule_GetDestructor

I noticed this while working on a type caster related to #3858 DLPack
happens to allow the destructor not to be defined on a capsule, and I
encountered such a case. See:

e2bdd3bee8/include/dlpack/dlpack.h (L219)

* Add test for the fix.

* Update tests/test_pytypes.cpp

I tried this locally and it works!
I never knew that there are cases where `reinterpret_cast` does not work but `static_cast` does. Let's see if all compilers are happy with this.

Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>

* style: pre-commit fixes

Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgkio@gmail.com>
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-07 12:27:54 -07:00
..
extra_python_package feat(cmake): add installation support for pkg-config dependency detection (#4077) 2022-08-09 00:02:45 -04:00
extra_setuptools chore: drop Python 3.5 (#3719) 2022-02-11 19:06:16 -05:00
test_cmake_build chore: drop Python 3.5 (#3719) 2022-02-11 19:06:16 -05:00
test_embed embed.h Python 3.11 `config.use_environment=1` + `PYTHONPATH` test (#4119) 2022-08-21 09:44:01 -07:00
CMakeLists.txt Add `error_scope` to `detail::get_internals()` (#3981) 2022-05-31 11:51:13 -07:00
conftest.py Report `C++ Info:` via `pytest_report_header()` (#4046) 2022-07-07 17:51:44 -07:00
constructor_stats.h test: ConstructorStats newline (PyPy) (#4167) 2022-08-29 23:25:01 -04:00
cross_module_gil_utils.cpp chore: enable clang-tidy check modernize-use-nullptr (#3881) 2022-04-18 11:09:45 -04:00
cross_module_interleaved_error_already_set.cpp Add `error_scope` to `detail::get_internals()` (#3981) 2022-05-31 11:51:13 -07:00
env.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
local_bindings.h Fully-automatic clang-format with include reordering (#3713) 2022-02-10 12:17:07 -08:00
object.h Fully-automatic clang-format with include reordering (#3713) 2022-02-10 12:17:07 -08:00
pybind11_cross_module_tests.cpp Fully-automatic clang-format with include reordering (#3713) 2022-02-10 12:17:07 -08:00
pybind11_tests.cpp Report `C++ Info:` via `pytest_report_header()` (#4046) 2022-07-07 17:51:44 -07:00
pybind11_tests.h Dropping MSVC 2015 (#3722) 2022-02-14 11:36:22 -08:00
pytest.ini chore: drop Python 3.5 (#3719) 2022-02-11 19:06:16 -05:00
requirements.txt Fix: 3.11 beta support (#3923) 2022-07-06 16:35:12 -04:00
test_async.cpp Fully-automatic clang-format with include reordering (#3713) 2022-02-10 12:17:07 -08:00
test_async.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_buffers.cpp Fully-automatic clang-format with include reordering (#3713) 2022-02-10 12:17:07 -08:00
test_buffers.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_builtin_casters.cpp Add `-DPYBIND11_WERROR=ON` to mingw cmake commands (#4073) 2022-08-01 06:18:48 -07:00
test_builtin_casters.py Cast bytearray to string (#3707) 2022-02-23 18:21:03 -05:00
test_call_policies.cpp Fully-automatic clang-format with include reordering (#3713) 2022-02-10 12:17:07 -08:00
test_call_policies.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_callbacks.cpp Fully-automatic clang-format with include reordering (#3713) 2022-02-10 12:17:07 -08:00
test_callbacks.py chore: drop Python 3.5 (#3719) 2022-02-11 19:06:16 -05:00
test_chrono.cpp Fully-automatic clang-format with include reordering (#3713) 2022-02-10 12:17:07 -08:00
test_chrono.py chore: drop Python 3.5 (#3719) 2022-02-11 19:06:16 -05:00
test_class.cpp Dropping MSVC 2015 (#3722) 2022-02-14 11:36:22 -08:00
test_class.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_const_name.cpp Dropping MSVC 2015 (#3722) 2022-02-14 11:36:22 -08:00
test_const_name.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_constants_and_functions.cpp enable two new clang-tidy checks (#3988) 2022-06-06 12:15:45 -04:00
test_constants_and_functions.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_copy_move.cpp Fix py::cast from pytype rvalue to pytype (#3949) 2022-05-16 13:51:01 -07:00
test_copy_move.py Fix py::cast from pytype rvalue to pytype (#3949) 2022-05-16 13:51:01 -07:00
test_custom_type_casters.cpp Open pybind11 namespace with consistent visility. (#4098) 2022-08-01 11:31:31 -07:00
test_custom_type_casters.py cast: Qualify symbol usage in PYBIND11_TYPE_CASTER (#3758) 2022-02-25 13:25:23 -08:00
test_custom_type_setup.cpp Add `custom_type_setup` attribute (#3287) 2021-09-24 12:08:22 -07:00
test_custom_type_setup.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_docstring_options.cpp Fully-automatic clang-format with include reordering (#3713) 2022-02-10 12:17:07 -08:00
test_docstring_options.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_eigen.cpp test_eigen.py test_nonunit_stride_to_python bug fix (ASAN failure) (#4217) 2022-10-07 09:20:38 -07:00
test_eigen.py test_eigen.py test_nonunit_stride_to_python bug fix (ASAN failure) (#4217) 2022-10-07 09:20:38 -07:00
test_enum.cpp Fully-automatic clang-format with include reordering (#3713) 2022-02-10 12:17:07 -08:00
test_enum.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_eval.cpp Fully-automatic clang-format with include reordering (#3713) 2022-02-10 12:17:07 -08:00
test_eval.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_eval_call.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_exceptions.cpp For PyPy only, re-enable old behavior (runs the risk of masking bugs) (#4079) 2022-07-21 06:38:00 -07:00
test_exceptions.h Fully-automatic clang-format with include reordering (#3713) 2022-02-10 12:17:07 -08:00
test_exceptions.py [pre-commit.ci] pre-commit autoupdate (#4104) 2022-08-03 11:38:07 -04:00
test_factory_constructors.cpp Dropping MSVC 2015 (#3722) 2022-02-14 11:36:22 -08:00
test_factory_constructors.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_gil_scoped.cpp Fully-automatic clang-format with include reordering (#3713) 2022-02-10 12:17:07 -08:00
test_gil_scoped.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_iostream.cpp Dropping MSVC 2015 (#3722) 2022-02-14 11:36:22 -08:00
test_iostream.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_kwargs_and_defaults.cpp More systematic gcc & clang coverage (#4083) 2022-07-21 06:40:34 -07:00
test_kwargs_and_defaults.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_local_bindings.cpp Fully-automatic clang-format with include reordering (#3713) 2022-02-10 12:17:07 -08:00
test_local_bindings.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_methods_and_attributes.cpp Replace error printing code gated by NDEBUG with a new flag: PYBIND11_DETAILED_ERROR_MESSAGES (#3913) 2022-05-02 15:30:19 -04:00
test_methods_and_attributes.py Fix: 3.11 beta support (#3923) 2022-07-06 16:35:12 -04:00
test_modules.cpp Add missing error handling to `module_::def_submodule` (#3973) 2022-05-28 16:40:57 -07:00
test_modules.py Add missing error handling to `module_::def_submodule` (#3973) 2022-05-28 16:40:57 -07:00
test_multiple_inheritance.cpp Fully-automatic clang-format with include reordering (#3713) 2022-02-10 12:17:07 -08:00
test_multiple_inheritance.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_numpy_array.cpp fix: avoid `catch (...)` for expected `import numpy` failures (#3974) 2022-05-26 11:07:40 -04:00
test_numpy_array.py chore: drop Python 3.5 (#3719) 2022-02-11 19:06:16 -05:00
test_numpy_dtypes.cpp fix: avoid `catch (...)` for expected `import numpy` failures (#3974) 2022-05-26 11:07:40 -04:00
test_numpy_dtypes.py Expand dtype accessors (#3868) 2022-04-14 10:53:16 -04:00
test_numpy_vectorize.cpp fix: avoid `catch (...)` for expected `import numpy` failures (#3974) 2022-05-26 11:07:40 -04:00
test_numpy_vectorize.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_opaque_types.cpp Fully-automatic clang-format with include reordering (#3713) 2022-02-10 12:17:07 -08:00
test_opaque_types.py chore: drop Python 3.5 (#3719) 2022-02-11 19:06:16 -05:00
test_operator_overloading.cpp Fully-automatic clang-format with include reordering (#3713) 2022-02-10 12:17:07 -08:00
test_operator_overloading.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_pickling.cpp Test pickling a simple callable (does not work). (#3906) 2022-05-02 12:39:36 -07:00
test_pickling.py Test pickling a simple callable (does not work). (#3906) 2022-05-02 12:39:36 -07:00
test_pytypes.cpp fix: PyCapsule_GetDestructor is allowed to return a nullptr destructor (#4221) 2022-10-07 12:27:54 -07:00
test_pytypes.py fix: PyCapsule_GetDestructor is allowed to return a nullptr destructor (#4221) 2022-10-07 12:27:54 -07:00
test_sequences_and_iterators.cpp docs: Correct minor typos (#3721) 2022-02-11 10:42:48 -05:00
test_sequences_and_iterators.py chore: drop Python 3.5 (#3719) 2022-02-11 19:06:16 -05:00
test_smart_ptr.cpp Open pybind11 namespace with consistent visility. (#4098) 2022-08-01 11:31:31 -07:00
test_smart_ptr.py chore: drop Python 3.5 (#3719) 2022-02-11 19:06:16 -05:00
test_stl.cpp Open pybind11 namespace with consistent visility. (#4098) 2022-08-01 11:31:31 -07:00
test_stl.py Add anyset & frozenset, enable copying (cast) to std::set (#3901) 2022-05-05 12:09:56 -07:00
test_stl_binders.cpp Fully-automatic clang-format with include reordering (#3713) 2022-02-10 12:17:07 -08:00
test_stl_binders.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_tagbased_polymorphic.cpp Open pybind11 namespace with consistent visility. (#4098) 2022-08-01 11:31:31 -07:00
test_tagbased_polymorphic.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_thread.cpp Fully-automatic clang-format with include reordering (#3713) 2022-02-10 12:17:07 -08:00
test_thread.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_union.cpp Fix assertion failure for unions (#1685) (#1709) 2019-06-11 23:28:58 +02:00
test_union.py Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688) 2022-02-10 18:28:08 -08:00
test_virtual_functions.cpp chore: bump clang-tidy to 13 (#3997) 2022-07-13 09:06:32 -05:00
test_virtual_functions.py chore: drop Python 3.5 (#3719) 2022-02-11 19:06:16 -05:00
valgrind-numpy-scipy.supp docs: fix various typos (#3075) 2021-07-04 19:58:35 -04:00
valgrind-python.supp chore: get PyPy 3.7 wheels using NumPy 1.20 (#2837) 2021-01-31 17:29:09 -05:00