Commit Graph

1540 Commits

Author SHA1 Message Date
Ralf W. Grosse-Kunstleve
13076e4fb7 Remove PYBIND11_TYPE_CASTER_SOURCE_FILE_LINE macro completely. Some small extra cleanup. 2022-07-01 18:48:23 -07:00
Ralf W. Grosse-Kunstleve
ae38889322 Remove PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL macro completely. 2022-07-01 18:15:32 -07:00
Ralf W. Grosse-Kunstleve
11adace1ea Fix small oversight (src_loc::here() -> src_loc{nullptr, 0}). 2022-07-01 16:52:54 -07:00
Ralf W. Grosse-Kunstleve
68b155a10c Use TypeCasterType::name.sloc instead of source_file_line.sloc
Manual re-verification:

```
+++ b/tests/test_type_caster_odr_guard_2.cpp
-    // m.def("pass_vector_type_mrc", mrc_ns::pass_vector_type_mrc);
+    m.def("pass_vector_type_mrc", mrc_ns::pass_vector_type_mrc);
```

```
>           assert num_violations == 1
E           assert 2 == 1

num_violations = 2

test_type_caster_odr_guard_1.py:51: AssertionError
```
2022-07-01 16:40:33 -07:00
Ralf W. Grosse-Kunstleve
44966dab16 Work scr_loc into descr 2022-07-01 16:40:33 -07:00
Ralf W. Grosse-Kunstleve
38c25655b7 Add missing include (discovered via google-internal testing). 2022-07-01 16:40:33 -07:00
Ralf W. Grosse-Kunstleve
9ba32bde5e Disable type_caster ODR guard for __INTEL_COMPILER (see comment). Also turn off printf. 2022-06-28 20:43:09 -07:00
Ralf W. Grosse-Kunstleve
37e583bab8 Use source_file_line_from_sloc in type_caster_odr_guard_registry 2022-06-28 19:38:47 -07:00
Ralf W. Grosse-Kunstleve
4b6d3b87a7 clang-tidy suggested fixes 2022-06-28 08:56:54 -07:00
Ralf W. Grosse-Kunstleve
11e858d0da tu_local_descr with src_loc experiment 2022-06-28 08:42:44 -07:00
Ralf W. Grosse-Kunstleve
3ea37002b1 Eliminate need for PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL macro.
Copying code first developed by @amauryfa. I tried this at an earlier stage, but by itself this was insufficient. In the meantime I added in the TU-local mechanisms: trying again.

Passes local testing:
```
DISABLED std::system_error: ODR VIOLATION DETECTED: pybind11::detail::type_caster<mrc_ns::type_mrc>: SourceLocation1="/usr/local/google/home/rwgk/forked/pybind11/tests/test_type_caster_odr_guard_1.cpp:18", SourceLocation2="/usr/local/google/home/rwgk/forked/pybind11/tests/test_type_caster_odr_guard_2.cpp:19"
C++ Info: Debian Clang 13.0.1 C++17 __pybind11_internals_v4_clang_libstdcpp_cxxabi1002_sh_def__
=========================================================== test session starts ============================================================
platform linux -- Python 3.9.12, pytest-6.2.3, py-1.10.0, pluggy-0.13.1 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /usr/local/google/home/rwgk/forked/pybind11/tests, configfile: pytest.ini
collected 6 items

test_type_caster_odr_guard_1.py::test_type_mrc_to_python PASSED
test_type_caster_odr_guard_1.py::test_type_mrc_from_python PASSED
test_type_caster_odr_guard_1.py::test_type_caster_odr_registry_values PASSED
test_type_caster_odr_guard_1.py::test_type_caster_odr_violation_detected_counter PASSED
test_type_caster_odr_guard_2.py::test_type_mrc_to_python PASSED
test_type_caster_odr_guard_2.py::test_type_mrc_from_python PASSED

============================================================ 6 passed in 0.01s =============================================================
```
2022-06-28 07:10:20 -07:00
Ralf W. Grosse-Kunstleve
4e13032e81 Introduce make_caster_intrinsic<T>, to be able to undo the 2 changes from load_type to load_type<T>. This is to avoid breaking 2 pybind11::detail::load_type() calls found in the wild (Google global testing).
One of the breakages in the wild was: 0f0f600767/python/tensorstore/subscript_method.h (L61)
2022-06-28 00:20:53 -07:00
Ralf W. Grosse-Kunstleve
1263ce9ee2 Add test_type_caster_odr_registry_values(), test_type_caster_odr_violation_detected_counter() 2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
d2bafaeba7 New PYBIND11_TYPE_CASTER_ODR_GUARD_STRICT option (current on by default). 2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
21fc6b31c7 Mark tu_local_no_data_always_false operator bool as explicit (clang-tidy). See also: https://stackoverflow.com/questions/39995573/when-can-i-use-explicit-operator-bool-without-a-cast 2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
ec8b8b68c7 Remove comments that are (now) more distracting than helpful. 2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
2e6e833929 Move type_caster_odr_guard to type_caster_odr_guard.h 2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
1acc9d0555 type_caster_odr_guard_impl() cleanup 2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
5d45055a58 Fix ifdef for pragma GCC diagnostic. 2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
5aaf96a382 Experiment: Try any C++17 compiler. 2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
3d064fcab3 Replace throw err; to resolve clang-tidy error. 2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
ed4b50bb86 IWYU cleanup of detail/type_caster_odr_guard.h 2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
6a6eb6cac8 define PYBIND11_DETAIL_ODR_GUARD_IMPL_THROW_DISABLED true in test_odr_guard_1,2.cpp 2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
a34771aeda Move cpp_version_in_use() from cast.h to pybind11_tests.cpp 2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
cfd98a7de2 Fix off-by-one in source_file_line_basename() 2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
a8144d971d Resolve clang-tidy error. 2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
15db5e5fea Set PYBIND11_TYPE_CASTER_ODR_GUARD_ON automatically. 2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
e515940252 Minor cleanup. 2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
d390918d88 Introduce PYBIND11_TYPE_CASTER_ODR_GUARD_ON (but not set automatically). 2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
47c4e7939e Add source_file_line_basename() 2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
0feb0be8c2 Show C++ version along with ODR VIOLATION DETECTED message. 2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
a598fe6931 Replace C++17 syntax. Compiles with Debian clang 13 C++11 mode, but fails to link. Trying GitHub Actions anyway to see if there are any platforms that support https://en.cppreference.com/w/cpp/language/tu_local before C++20. Note that Debian clang 13 C++17 works locally. 2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
b8876ac2af Strip ./ from source_file_line 2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
0f9bb4c892 load_type fixes & follow-on cleanup 2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
24d450bf74 Add more PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL; resolves "unused" warning when compiling test_custom_type_casters.cpp 2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
3a95ae1165 Replace PYBIND11_TYPE_CASTER_UNIQUE_IDENTIFIER with PYBIND11_TYPE_CASTER_SOURCE_FILE_LINE, baked into PYBIND11_TYPE_CASTER macro. 2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
e06518da7d Add PYBIND11_SOURCE_FILE_LINE macro. 2022-06-28 00:20:50 -07:00
Ralf W. Grosse-Kunstleve
1522f57d2d WIP 2022-06-28 00:20:50 -07:00
Ralf W. Grosse-Kunstleve
55530437fc Small simplification of odr_guard_impl() 2022-06-28 00:20:50 -07:00
Ralf W. Grosse-Kunstleve
3718516ff5 Cleanup of tests. Systematically insert if (make_caster<T>::translation_unit_local) { 2022-06-28 00:20:50 -07:00
Ralf W. Grosse-Kunstleve
509506955b VERY MESSY SNAPSHOT of WIP, this was the starting point for cl/454658864, which has more changes on top. 2022-06-28 00:20:50 -07:00
Ralf W. Grosse-Kunstleve
5c7e77c575 Add odr_guard_registry() used in type_caster_odr_guard() default constructor. 2022-06-28 00:20:50 -07:00
Ralf W. Grosse-Kunstleve
c84f3817c4 Insert type_caster_odr_guard<> (an empty struct to start with). 2022-06-28 00:20:50 -07:00
Ralf W. Grosse-Kunstleve
cad2609381 Merge branch 'master' into smart_holder 2022-06-27 22:24:23 -07:00
Xiaofei Wang
c0cfe95b1b
Support loading unique_ptr<Derived> as unique_ptr<Base>. (#4031)
* Support loading unique_ptr<derived> as unique_ptr<base>.

* Fix incorrect test

* pre commit fix

* Fix clang tidy

* Resolve comments

* Resolve comments
2022-06-27 22:21:28 -07:00
Aaron Gokaslan
0964a9093a
Add a missing std::move in numpy.h (#4005) 2022-06-14 14:20:26 -04:00
Aaron Gokaslan
e2dcd95407
chore: optimize dictionary access in strip_padding numpy (#3994)
* emplace field descriptors

* reserve sufficient capacity

* remove std::move

* properly iterate through dict

* make handle casting more explicit

* Revert to old dict api
2022-06-06 22:33:28 -04:00
Maarten Baert
918892b97e
Make dtype::num() return type consistent with other functions (#3995) 2022-06-06 19:41:38 -04:00
Aaron Gokaslan
42a41bf3e7
remove useless ctor (#3989) 2022-06-03 15:18:06 -04:00
Ralf W. Grosse-Kunstleve
cf2c307e7b Merge branch 'master' into sh_merge_master 2022-06-02 16:26:40 -07:00