1. 31 Oct, 2022 3 commits
    • fix: unicode surrogate character in Python exception message. (#4297) · 3fb36a99
      * Fix & test for issue #4288 (unicode surrogate character in Python exception message).
      
      * DRY `message_unavailable_exc`
      
      * fix: add a constexpr
      
      Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
      
      * style: pre-commit fixes
      
      Co-authored-by: Henry Schreiner <HenrySchreinerIII@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>
      Ralf W. Grosse-Kunstleve committed
    • Add `PYBIND11_SIMPLE_GIL_MANAGEMENT` option (cmake, C++ define) (#4216) · 15fde1de
      * Add option to force the use of the PYPY GIL scoped acquire/release logic to support nested gil access, see https://github.com/pybind/pybind11/issues/1276 and https://github.com/pytorch/pytorch/issues/83101
      
      * Apply suggestions from code review
      
      * Update CMakeLists.txt
      
      * docs: update upgrade guide
      
      * Update docs/upgrade.rst
      
      * All bells & whistles.
      
      * Add Reminder to common.h, so that we will not forget to purge `!WITH_THREAD` branches when dropping Python 3.6
      
      * New sentence instead of semicolon.
      
      * Temporarily pull in snapshot of PR #4246
      
      * Add `test_release_acquire`
      
      * Add more unit tests for nested gil locking
      
      * Add test_report_builtins_internals_keys
      
      * Very minor enhancement: sort list only after filtering.
      
      * Revert change in docs/upgrade.rst
      
      * Add test_multi_acquire_release_cross_module, while also forcing unique PYBIND11_INTERNALS_VERSION for cross_module_gil_utils.cpp
      
      * Hopefully fix apparently new ICC error.
      
      ```
      2022-10-28T07:57:54.5187728Z -- The CXX compiler identification is Intel 2021.7.0.20220726
      ...
      2022-10-28T07:58:53.6758994Z icpc: remark #10441: The Intel(R) C++ Compiler Classic (ICC) is deprecated and will be removed from product release in the second half of 2023. The Intel(R) oneAPI DPC++/C++ Compiler (ICX) is the recommended compiler moving forward. Please transition to use this compiler. Use '-diag-disable=10441' to disable this message.
      2022-10-28T07:58:54.5801597Z In file included from /home/runner/work/pybind11/pybind11/include/pybind11/detail/../detail/type_caster_base.h(15),
      2022-10-28T07:58:54.5803794Z                  from /home/runner/work/pybind11/pybind11/include/pybind11/detail/../cast.h(15),
      2022-10-28T07:58:54.5805740Z                  from /home/runner/work/pybind11/pybind11/include/pybind11/detail/../attr.h(14),
      2022-10-28T07:58:54.5809556Z                  from /home/runner/work/pybind11/pybind11/include/pybind11/detail/class.h(12),
      2022-10-28T07:58:54.5812154Z                  from /home/runner/work/pybind11/pybind11/include/pybind11/pybind11.h(13),
      2022-10-28T07:58:54.5948523Z                  from /home/runner/work/pybind11/pybind11/tests/cross_module_gil_utils.cpp(13):
      2022-10-28T07:58:54.5949009Z /home/runner/work/pybind11/pybind11/include/pybind11/detail/../detail/internals.h(177): error #2282: unrecognized GCC pragma
      2022-10-28T07:58:54.5949374Z       PYBIND11_TLS_KEY_INIT(tstate)
      2022-10-28T07:58:54.5949579Z       ^
      2022-10-28T07:58:54.5949695Z
      ```
      
      * clang-tidy fixes
      
      * Workaround for PYPY WIN exitcode None
      
      * Revert "Temporarily pull in snapshot of PR #4246"
      
      This reverts commit 23ac16e859150f27fda25ca865cabcb4444e0770.
      
      * Another workaround for PYPY WIN exitcode None
      
      * Clean up how the tests are run "run in process" Part 1: uniformity
      
      * Clean up how the tests are run "run in process" Part 2: use `@pytest.mark.parametrize` and clean up the naming.
      
      * Skip some tests `#if defined(THREAD_SANITIZER)` (tested with TSAN using the Google-internal toolchain).
      
      * Run all tests again but ignore ThreadSanitizer exitcode 66 (this is less likely to mask unrelated ThreadSanitizer issues in the future).
      
      * bug fix: missing common.h include before using `PYBIND11_SIMPLE_GIL_MANAGEMENT`
      
      For the tests in the github CI this does not matter, because
      `PYBIND11_SIMPLE_GIL_MANAGEMENT` is always defined from the command line,
      but when monkey-patching common.h locally, it matters.
      
      * if process.exitcode is None: assert t_delta > 9.9
      
      * More sophisiticated `_run_in_process()` implementation, clearly reporting `DEADLOCK`, additionally exercised via added `intentional_deadlock()`
      
      * Wrap m.intentional_deadlock in a Python function, for `ForkingPickler` compatibility.
      
      ```
      >       ForkingPickler(file, protocol).dump(obj)
      E       TypeError: cannot pickle 'PyCapsule' object
      ```
      
      Observed with all Windows builds including mingw but not PyPy, and macos-latest with Python 3.9, 3.10, 3.11 but not 3.6.
      
      * Add link to potential solution for WOULD-BE-NICE-TO-HAVE feature.
      
      * Add `SKIP_IF_DEADLOCK = True` option, to not pollute the CI results with expected `DEADLOCK` failures while we figure out what to do about them.
      
      * Add COPY-PASTE-THIS: gdb ... command (to be used for debugging the detected deadlock)
      
      * style: pre-commit fixes
      
      * Do better than automatic pre-commit fixes.
      
      * Add `PYBIND11_SIMPLE_GIL_MANAGEMENT` to `pytest_report_header()` (so that we can easily know when harvesting deadlock information from the CI logs).
      
      Co-authored-by: Arnim Balzer <arnim@seechange.ai>
      Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
      Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
      Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
      Chekov2k committed
    • fix: improve bytes to str decoding error handling (#4294) · 5b395c9b
      * (bugfix): Improve bytes to str decoding error handling
      
      * regroup test
      
      * Further broaden tests
      
      * Add another decode error test
      
      * Fix bug in tests
      
      * Reviewer suggestions
      Aaron Gokaslan committed
  2. 26 Oct, 2022 1 commit
  3. 24 Oct, 2022 2 commits
  4. 23 Oct, 2022 1 commit
    • Fix casts to void* (#4275) · ce63bcb9
      * Fix casts to void*
      
      * Improve tests
      
      * style: pre-commit fixes
      
      * remove c style cast
      
      Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
      Co-authored-by: Aaron Gokaslan <aaronGokaslan@gmail.com>
      Lalaland committed
  5. 21 Oct, 2022 3 commits
  6. 20 Oct, 2022 3 commits
  7. 17 Oct, 2022 2 commits
  8. 12 Oct, 2022 2 commits
  9. 11 Oct, 2022 2 commits
  10. 10 Oct, 2022 1 commit
    • Reproducer and fix for issue encountered in smart_holder update. (#4228) · da104a9e
      * Reproducer for issue encountered in smart_holder update.
      
      * clang-tidy compatibility (untested).
      
      * Add `enable_if_t` to workaround.
      
      * Bug fix: Move `PYBIND11_USING_WORKAROUND_FOR_CUDA_11_4_THROUGH_8` determination to detail/common.h
      
      So that it actually is defined in pybind11.h
      
      * Try using the workaround (which is nicer than the original code) universally.
      
      * Reduce reproducer for CUDA 11.7 issue encountered in smart_holder update.
      
      This commit tested in isolation on top of current master + first version of reproducer (62311eb431849d135a5db84f6c75ec390f2ede7c).
      
      Succeeds with Debian Clang 14.0.6 C++17 (and probably all other compilers).
      
      Fails for CUDA 11.7:
      
      ```
      cd /build/tests && /usr/local/cuda/bin/nvcc -forward-unknown-to-host-compiler -Dpybind11_tests_EXPORTS -I/mounted_pybind11/include -isystem=/usr/include/python3.10 -g --generate-code=arch=compute_52,code=[compute_52,sm_52] -Xcompiler=-fPIC -Xcompiler=-fvisibility=hidden -Werror all-warnings -std=c++17 -MD -MT tests/CMakeFiles/pybind11_tests.dir/test_class.cpp.o -MF CMakeFiles/pybind11_tests.dir/test_class.cpp.o.d -x cu -c /mounted_pybind11/tests/test_class.cpp -o CMakeFiles/pybind11_tests.dir/test_class.cpp.o
      /mounted_pybind11/tests/test_class.cpp(53): error: more than one instance of overloaded function "pybind11::class_<type_, options...>::def [with type_=test_class::pr4220_tripped_over_this::Empty0, options=<>]" matches the argument list:
                  function template "pybind11::class_<test_class::pr4220_tripped_over_this::Empty0> &pybind11::class_<type_, options...>::def(const char *, Func &&, const Extra &...) [with type_=test_class::pr4220_tripped_over_this::Empty0, options=<>]"
      /mounted_pybind11/include/pybind11/pybind11.h(1557): here
                  function template "pybind11::class_<test_class::pr4220_tripped_over_this::Empty0> &pybind11::class_<type_, options...>::def(const T &, const Extra &...) [with type_=test_class::pr4220_tripped_over_this::Empty0, options=<>]"
      /mounted_pybind11/include/pybind11/pybind11.h(1586): here
                  argument types are: (const char [8], <unknown-type>)
                  object type is: pybind11::class_<test_class::pr4220_tripped_over_this::Empty0>
      
      1 error detected in the compilation of "/mounted_pybind11/tests/test_class.cpp".
      ```
      Ralf W. Grosse-Kunstleve committed
  11. 07 Oct, 2022 3 commits
  12. 06 Oct, 2022 1 commit
  13. 04 Oct, 2022 2 commits
  14. 03 Oct, 2022 1 commit
  15. 27 Sep, 2022 1 commit
  16. 25 Sep, 2022 1 commit
  17. 21 Sep, 2022 2 commits
  18. 20 Sep, 2022 2 commits
  19. 19 Sep, 2022 1 commit
  20. 14 Sep, 2022 2 commits
  21. 13 Sep, 2022 1 commit
  22. 07 Sep, 2022 1 commit
  23. 30 Aug, 2022 2 commits