Commit Graph

2925 Commits

Author SHA1 Message Date
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
bcd1800cf4 Turn off flake8 completely for ubench/
To suppress these new errors (apparently after a flake8 upgrade):

```
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

ubench/holder_comparison.py:96:38: B023 Function definition does not bind loop variable 'nb1'.
                    assert int(round(nb1.sum())) == data_size
                                     ^
ubench/holder_comparison.py:96:53: B023 Function definition does not bind loop variable 'data_size'.
                    assert int(round(nb1.sum())) == data_size
                                                    ^
ubench/holder_comparison.py:99:25: B023 Function definition does not bind loop variable 'nb1'.
                        nb1.sum()
                        ^
ubench/holder_comparison.py:103:28: B023 Function definition does not bind loop variable 'nb1'.
                    assert nb1.add(nb2) == data_size
                           ^
ubench/holder_comparison.py:103:36: B023 Function definition does not bind loop variable 'nb2'.
                    assert nb1.add(nb2) == data_size
                                   ^
ubench/holder_comparison.py:103:44: B023 Function definition does not bind loop variable 'data_size'.
                    assert nb1.add(nb2) == data_size
                                           ^
ubench/holder_comparison.py:106:25: B023 Function definition does not bind loop variable 'nb1'.
                        nb1.add(nb2)
                        ^
ubench/holder_comparison.py:106:33: B023 Function definition does not bind loop variable 'nb2'.
                        nb1.add(nb2)
                                ^
ubench/holder_comparison_extract_sheet_data.py:21:16: B023 Function definition does not bind loop variable 'header_row'.
            if header_row:
               ^
ubench/holder_comparison_extract_sheet_data.py:22:20: B023 Function definition does not bind loop variable 'header'.
                if header is None:  # type: ignore[unreachable]
                   ^
ubench/holder_comparison_extract_sheet_data.py:23:36: B023 Function definition does not bind loop variable 'header_row'.
                    print(",".join(header_row))
                                   ^
ubench/holder_comparison_extract_sheet_data.py:25:28: B023 Function definition does not bind loop variable 'header'.
                    assert header == header_row
                           ^
ubench/holder_comparison_extract_sheet_data.py:25:38: B023 Function definition does not bind loop variable 'header_row'.
                    assert header == header_row
                                     ^
ubench/holder_comparison_extract_sheet_data.py:26:16: B023 Function definition does not bind loop variable 'data_row'.
            if data_row is not None:
               ^
ubench/holder_comparison_extract_sheet_data.py:27:32: B023 Function definition does not bind loop variable 'data_row'.
                print(",".join(data_row))  # type: ignore[unreachable]
                               ^
ubench/holder_comparison_extract_sheet_data.py:28:17: B023 Function definition does not bind loop variable 'data_row_buffer'.
                data_row_buffer.append(data_row)
                ^
ubench/holder_comparison_extract_sheet_data.py:28:40: B023 Function definition does not bind loop variable 'data_row'.
                data_row_buffer.append(data_row)
                                       ^
ubench/holder_comparison_extract_sheet_data.py:29:20: B023 Function definition does not bind loop variable 'header_row'.
            return header_row
                   ^
```
2022-07-09 21:50:36 -07:00
Ralf W. Grosse-Kunstleve
3bd20627d3 Tracking ci.yml changes from master. 2022-07-09 21:50:08 -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 (#4051)
* 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). (#4049)
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 #4022, 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() (#4046)
* 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. (#4043) 2022-07-06 14:29:20 -07:00
Henry Schreiner
0ab1fcfb1c
docs: update changelog (#4042)
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
2022-07-06 16:36:05 -04:00
Aaron Gokaslan
2af163d9c7
Fix: 3.11 beta support (#3923)
* 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
pre-commit-ci[bot]
c42e3ab793
[pre-commit.ci] pre-commit autoupdate (#4041)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 22.3.0 → 22.6.0](https://github.com/psf/black/compare/22.3.0...22.6.0)
- [github.com/Lucas-C/pre-commit-hooks: v1.2.0 → v1.3.0](https://github.com/Lucas-C/pre-commit-hooks/compare/v1.2.0...v1.3.0)
- [github.com/PyCQA/pylint: v2.14.3 → v2.14.4](https://github.com/PyCQA/pylint/compare/v2.14.3...v2.14.4)
- [github.com/pre-commit/mirrors-clang-format: v14.0.5 → v14.0.6](https://github.com/pre-commit/mirrors-clang-format/compare/v14.0.5...v14.0.6)

* Update blacken-docs

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
2022-07-04 22:21:59 -04:00
dependabot[bot]
bc1f9f9ba6
chore(deps): bump actions/setup-python from 3 to 4 (#3999)
* chore(deps): bump actions/setup-python from 3 to 4

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Apply suggestions from code review

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
2022-07-04 10:24:55 -04:00
Henry Schreiner
5a3a1e3415
chore: simpler dependabot (#4035)
Ignores no longer needed after April 2022. Dependabot keeps the same style pinning now.
2022-07-04 10:24:34 -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 (#4038)
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
Masaki Kozuki
374a5b000a
[docs] Fix "Enumerations and internal types" example (#4034)
* Fix binding of `Pet::Attributes`

* omit `attributes` as it's not needed

Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
2022-06-28 12:38:37 -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
3fc4833433 Add test for stl.h / stl_bind.h mix.
Manually verified that the ODR guard detects the ODR violation:

```
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
...
================================================================= FAILURES =================================================================
_____________________________________________ test_type_caster_odr_violation_detected_counter ______________________________________________

    def test_type_caster_odr_violation_detected_counter():
        ...
        else:
>           assert num_violations == 1
E           assert 2 == 1
E             +2
E             -1

num_violations = 2

test_type_caster_odr_guard_1.py:51: AssertionError
========================================================= short test summary info ==========================================================
FAILED test_type_caster_odr_guard_1.py::test_type_caster_odr_violation_detected_counter - assert 2 == 1
======================================================= 1 failed, 5 passed in 0.08s ========================================================
```
2022-06-28 00:20:53 -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
d8280df5d5 assert pybind11_tests.compiler_info is not None 2022-06-28 00:20:53 -07:00
Ralf W. Grosse-Kunstleve
491c2c7983 compiler_info MSVC fix. num_violations == 0 condition. 2022-06-28 00:20:53 -07:00
Ralf W. Grosse-Kunstleve
0d2bf264c8 Trying a new direction: show compiler info & std for UNEXPECTED: type_caster_odr_violation_detected_count() == 0 2022-06-28 00:20:53 -07:00
Ralf W. Grosse-Kunstleve
0c0f322e23 Yet another attempt to handle valgrind behavior. 2022-06-28 00:20:53 -07:00
Ralf W. Grosse-Kunstleve
5737b37dd4 Another attempt to handle valgrind behavior. 2022-06-28 00:20:53 -07:00
Ralf W. Grosse-Kunstleve
b10fc2ef15 Attempt to handle valgrind behavior. 2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
3cc2c9cd45 Apply clang-tidy suggestion. 2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
262998b317 Report UNEXPECTED: test_type_caster_odr_guard_2.cpp prevailed (but do not fail). 2022-06-28 00:20:52 -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
61a0bb8bd3 Rename test_odr_guard* to test_type_caster_odr_guard* 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
590171e6aa Add new header filename to CMakeLists.txt, test_files.py 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