* Add test_namespace_visibility
To probe environment/toolchain/platform-specific behavior under the exact same conditions as normal tests.
(An earlier version of this code was used to inform PR #4043.)
* Disable flake8 in ubench/holder_comparison_*.py, to suppress new & useless diagnostics.
* Disable namespace_visibility_1s.cpp (tosee if that resolves the MSVC and CUDA `test_cross_module_exception_translator` failures).
* Turn off flake8 completely for ubench (the Strip unnecessary `# noqa`s action un-helpfully removed the added noqa).
* Disable test_namespace_visibility completely. Just keep the two .cpp files, only setting the module docstring and doing nothing else.
* Rename test_namespace_visibility.py to test_exc_namespace_visibility.py, so that it is imported by pytest before test_exceptions.py
* Add `set_property(SOURCE namespace_visibility_1s.cpp PROPERTY LANGUAGE CUDA)`
* Add reference to PR #4054
* Complete the documentation (comments in test_exc_namespace_visibility.py).
* Rename namespace_visibility.h to namespace_visibility.inl, as suggested by @charlesbeattie
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
^
```
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());
```
* 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>
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.
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 =============================================================
```