1
0
mirror of https://github.com/pybind/pybind11.git synced 2025-03-03 13:03:20 +00:00
Commit Graph

1559 Commits

Author SHA1 Message Date
Ralf W. Grosse-Kunstleve
516811642e Fix clang-tidy error: 'auto reg' can be declared as 'auto *reg' [readability-qualified-auto,-warnings-as-errors] 2022-07-15 11:35:17 -07:00
Ralf W. Grosse-Kunstleve
696b80a59b Use no-destructor idiom for type_caster_odr_guard_registry, as suggested by @laramiel 2022-07-15 11:19:50 -07:00
Ralf W. Grosse-Kunstleve
671c2ce0d5 Update comment (incl. mention of deadsnakes known to not work as intended). 2022-07-14 08:10:23 -07:00
Ralf W. Grosse-Kunstleve
02ac969c80 Fully document the ODR violations in the ODR guard itself and introduce PYBIND11_TYPE_CASTER_ODR_GUARD_ON_IF_AVAILABLE 2022-07-13 19:11:53 -07:00
Ralf W. Grosse-Kunstleve
4dabffcbd5 Merge branch 'smart_holder' into odr_guard_sh 2022-07-13 17:40:20 -07:00
Ralf W. Grosse-Kunstleve
0ec9e31bbf Merge branch 'master' into sh_merge_master 2022-07-12 18:37:15 -07:00
Ralf W. Grosse-Kunstleve
023b3f32c8
Undo accidental one-line change under PR () 2022-07-12 12:02:20 -07:00
Ralf W. Grosse-Kunstleve
38688ec32c Some more work on source code comments. 2022-07-11 19:39:47 -07:00
Ralf W. Grosse-Kunstleve
2a14ee6e48 Add new test_descr_src_loc & and fix descr.h concat() src_loc bug discovered while working on the test. 2022-07-11 18:04:15 -07:00
Ralf W. Grosse-Kunstleve
bd0dbd7cf5 src_loc comments 2022-07-11 10:22:05 -07:00
Ralf W. Grosse-Kunstleve
75c659866f Minor tweaks looking at the PR with a fresh eye. 2022-07-11 10:14:26 -07:00
Ralf W. Grosse-Kunstleve
70f645f6d1 Merge branch 'smart_holder' into odr_guard_sh 2022-07-10 09:17:16 -07:00
Ralf W. Grosse-Kunstleve
27ce64fc43 Merge branch 'master' into sh_merge_master 2022-07-09 21:47:49 -07:00
Aaron Gokaslan
f9f00495a3
Properly visit self in >=3.9 traverse ()
* Properly visit self in >=3.9 traverse

* Add comment about 3.9 behavior
2022-07-09 21:43:53 -07:00
Ralf W. Grosse-Kunstleve
432bc5cfb5
Add std::string clean_type_id(const char *typeid_name) overload (in namespace detail). ()
Very minor refactoring to ease development and debugging.

Having to declare a local `std::string` has bugged me many times. Nice to get this little nuisance out of the way.

Extracted from PR , where it is used like this:

```
    std::fprintf(stdout,
                 "\nTYPE_CASTER_ODR_GUARD_IMPL %s %s\n",
                 clean_type_id(intrinsic_type_info.name()).c_str(),
                 source_file_line_from_sloc.c_str());
```
2022-07-07 19:08:10 -07:00
Ralf W. Grosse-Kunstleve
85bc088441
Report C++ Info: via pytest_report_header() ()
* Report `C++ Info:` from `pytest_configure()`

* Use pytest_report_header() as suggested by @skylion007
2022-07-07 17:51:44 -07:00
Ralf W. Grosse-Kunstleve
cd08869df1
PYBIND11_NAMESPACE consistency fixes. () 2022-07-06 14:29:20 -07:00
Aaron Gokaslan
2af163d9c7
Fix: 3.11 beta support ()
* Placeholder commit for 3.11 testing

* Does this fix it?

* Try suggestion

* Placeholder commit for 3.11 testing

* Does this fix it?

* Try suggestion

* fix: try using modern init for embedded interp

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* fix: error message changed in 3.11

* fix: apply logic in Python manually

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* fix autodetect dynamic attrs in 3.11

* fix: include error message if possible in error

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* ci: enable standard Python 3.11 testing

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* Make dynamic attrs condtiion exclusive to ver.

Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
2022-07-06 16:35:12 -04:00
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
Matthew Woehlke
479e9a50f3
Fix arrays with zero-size dimensions ()
When converting an array to an Eigen matrix, ignore the strides if any
dimension size is 0. If the array is empty, the strides aren't relevant,
and especially numpy ≥ 1.23 explicitly sets the strides to 0 in this
case. (See numpy commit dd5ab7b11520.)

Update tests to verify that this works, and continues to work.
2022-06-29 11:37:16 -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