1. 20 Sep, 2021 1 commit
  2. 13 Sep, 2021 1 commit
    • Ralf W. Grosse-Kunstleve's avatar
      Follow-on to PR #3254, to address user code breakages. (#3263) · 6c65ab59
      Ralf W. Grosse-Kunstleve authored
      * Restoring `const` removed from pytypes.h in PR #3254, adding tests reflective of user code that breaks when those `const` are removed.
      
      * clang-tidy NOLINTs (and one collateral fix).
      
      * Inserting PYBIND11_CONST_FOR_STRICT_PLATFORMS
      
      * Trying `defined(__APPLE__)`
      
      * Trying again: `auto it` for strict platforms.
      
      * Adding NOLINTNEXTLINE(bugprone-macro-parentheses), expanding comments.
      
      * Labeling all changes with `PR #3263`, for easy reference, and to make it easy to undo these changes if we decide to do so in the future.
      6c65ab59
  3. 10 Sep, 2021 2 commits
    • Laramie Leavitt's avatar
      Fix thread safety for pybind11 loader_life_support (#3237) · 0e599589
      Laramie Leavitt authored
      * Fix thread safety for pybind11 loader_life_support
      
      Fixes issue: https://github.com/pybind/pybind11/issues/2765
      
      This converts the vector of PyObjects to either a single void* or
      a per-thread void* depending on the WITH_THREAD define.
      
      The new field is used by each thread to construct a stack
      of loader_life_support frames that can extend the life of python
      objects.
      
      The pointer is updated when the loader_life_support object is allocated
      (which happens before a call) as well as on release.
      
      Each loader_life_support maintains a set of PyObject references
      that need to be lifetime extended; this is done by storing them
      in a c++ std::unordered_set and clearing the references when the
      method completes.
      
      * Also update the internals version as the internal struct is no longer compatible
      
      * Add test demonstrating threading works correctly.
      
      It may be appropriate to run this under msan/tsan/etc.
      
      * [pre-commit.ci] auto fixes from pre-commit.com hooks
      
      for more information, see https://pre-commit.ci
      
      * Update test to use lifetime-extended references rather than
      std::string_view, as that's a C++ 17 feature.
      
      * [pre-commit.ci] auto fixes from pre-commit.com hooks
      
      for more information, see https://pre-commit.ci
      
      * Make loader_life_support members private
      
      * Update version to dev2
      
      * Update test to use python threading rather than concurrent.futures
      
      * [pre-commit.ci] auto fixes from pre-commit.com hooks
      
      for more information, see https://pre-commit.ci
      
      * Remove unnecessary env in test
      
      * Remove unnecessary pytest in test
      
      * Use native C++ thread_local in place of python per-thread data structures to retain compatability
      
      * clang-format test_thread.cpp
      
      * Add a note about debugging the py::cast() error
      
      * thread_test.py now propagates exceptions on join() calls.
      
      * [pre-commit.ci] auto fixes from pre-commit.com hooks
      
      for more information, see https://pre-commit.ci
      
      
      
      * remove unused sys / merge
      
      * Update include order in test_thread.cpp
      
      * Remove spurious whitespace
      
      * Update comment / whitespace.
      
      * Address review comments
      
      * lint cleanup
      
      * Fix test IntStruct constructor.
      
      * Add explicit to constructor
      Co-authored-by: default avatarpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
      Co-authored-by: default avatarAaron Gokaslan <skylion.aaron@gmail.com>
      0e599589
    • Aaron Gokaslan's avatar
      maint(Clang-Tidy): readability-const-return (#3254) · ae07d4c6
      Aaron Gokaslan authored
      * Enable clang-tidy readability-const-return
      
      * PyTest functional
      
      * Fix regression
      
      * Fix actual regression
      
      * Remove one more NOLINT
      
      * Update comment
      ae07d4c6
  4. 09 Sep, 2021 2 commits
    • Aaron Gokaslan's avatar
      fix: Set __file__ constant when using eval_file (#1300) (#3233) · 4c6bee35
      Aaron Gokaslan authored
      * Set __file__ constant when using eval_file
      
      * Use const ref
      
      * Use a move instead
      
      * Revert
      
      * Improve test
      
      * Guard test with Python version
      
      * Fix tests
      
      * Dont support Python2 API
      
      * Drop Python2 eval __file__ support
      
      * Hack
      
      * Semisupport Python2
      
      * Take2
      
      * Remove Python2 support
      4c6bee35
    • Ralf W. Grosse-Kunstleve's avatar
      CodeHealth: Enabling clang-tidy google-explicit-constructor (#3250) · 6abf2baa
      Ralf W. Grosse-Kunstleve authored
      * Adding google-explicit-constructor to .clang-tidy
      
      * clang-tidy explicit attr.h (all automatic)
      
      * clang-tidy explicit cast.h (all automatic)
      
      * clang-tidy detail/init.h (1 NOLINT)
      
      * clang-tidy detail/type_caster_base.h (2 NOLINT)
      
      * clang-tidy pybind11.h (7 NOLINT)
      
      * clang-tidy detail/common.h (3 NOLINT)
      
      * clang-tidy detail/descr.h (2 NOLINT)
      
      * clang-tidy pytypes.h (23 NOLINT, only 1 explicit)
      
      * clang-tidy eigen.h (7 NOLINT, 0 explicit)
      
      * Adding 2 explicit in functional.h
      
      * Adding 4 explicit in iostream.h
      
      * clang-tidy numpy.h (1 NOLINT, 1 explicit)
      
      * clang-tidy embed.h (0 NOLINT, 1 explicit)
      
      * clang-tidy tests/local_bindings.h (0 NOLINT, 4 explicit)
      
      * clang-tidy tests/pybind11_cross_module_tests.cpp (0 NOLINT, 1 explicit)
      
      * clang-tidy tests/pybind11_tests.h (0 NOLINT, 2 explicit)
      
      * clang-tidy tests/test_buffers.cpp (0 NOLINT, 2 explicit)
      
      * clang-tidy tests/test_builtin_casters.cpp (0 NOLINT, 4 explicit)
      
      * clang-tidy tests/test_class.cpp (0 NOLINT, 6 explicit)
      
      * clang-tidy tests/test_copy_move.cpp (0 NOLINT, 7 explicit)
      
      * clang-tidy tests/test_embed/external_module.cpp (0 NOLINT, 1 explicit)
      
      * clang-tidy tests/test_embed/test_interpreter.cpp (0 NOLINT, 1 explicit)
      
      * clang-tidy tests/object.h (0 NOLINT, 2 explicit)
      
      * clang-tidy batch of fully automatic fixes.
      
      * Workaround for MSVC 19.16.27045.0 C++17 Python 2 C++ syntax error.
      6abf2baa
  5. 31 Aug, 2021 3 commits
    • Ralf W. Grosse-Kunstleve's avatar
      Minor follow-on to PR #1334 (Fix enum value's __int__ returning non-int when... · 49173e47
      Ralf W. Grosse-Kunstleve authored
      Minor follow-on to PR #1334 (Fix enum value's __int__ returning non-int when underlying type is bool or of char type) (#3232)
      
      * Minor tweaks.
      
      * Restoring tests/pybind11_tests.h version from master, removing just the comment and empty line that was added in PR #3087; those were made obsolete by the pragma cleanup that concluded with PR #3186.
      
      * More-to-the-point test for Python 3.
      49173e47
    • Ralf W. Grosse-Kunstleve's avatar
      Minor tweaks. (#3230) · a46f6237
      Ralf W. Grosse-Kunstleve authored
      * Minor tweaks.
      
      * Restoring tests/pybind11_tests.h version from master, removing just the comment and empty line that was added in PR #3087; those were made obsolete by the pragma cleanup that concluded with PR #3186.
      
      * [ci skip] Restoring tests/test_enum.py from master.
      a46f6237
    • Tailing Yuan's avatar
      fix: memory leak in cpp_function (#3228) (#3229) · d6474ed7
      Tailing Yuan authored
      
      
      * fix: memory leak in cpp_function (#3228)
      
      * add a test case to check objects are deconstructed in cpp_function
      
      * update the test case about cpp_function
      
      * fix the test case about cpp_function: remove "noexcept"
      
      * Actually calling func. CHECK(stat.alive() == 2); Manually verified that the new tests fails without the change in pybind11.h
      
      * Moving new test to test_callbacks.cpp,py, with small enhancements.
      
      * Removing new test from test_interpreter.cpp (after it was moved to test_callbacks.cpp,py). This restores test_interpreter.cpp to the current state on master.
      
      * Using py::detail::silence_unused_warnings(py_func); to make the intent clear.
      Co-authored-by: default avatarRalf W. Grosse-Kunstleve <rwgk@google.com>
      d6474ed7
  6. 28 Aug, 2021 1 commit
    • Ralf W. Grosse-Kunstleve's avatar
      Adding `ssize_t_cast` to support passing `size_t` or `ssize_t` values where... · 777352fc
      Ralf W. Grosse-Kunstleve authored
      Adding `ssize_t_cast` to support passing `size_t` or `ssize_t` values where `ssize_t` is needed. (#3219)
      
      * Trivial change to avoid (ssize_t) cast.
      
      * Demo for safe_ssize_t idea.
      
      * Removing safe_ssize_t.cpp (proof-of-concept code) to not upset the GHA Format workflow.
      
      * Completing changes in pytypes.h
      
      * New ssize_t_cast (better replacement for safe_ssize_t).
      
      * clang-format-diff (no manual changes).
      
      * bytes_ssize_t -Wnarrowing reproducer (see PR #2692).
      
      * Backing out tuple(), list() ssize_t support, for compatibility with older compilers (to resolve link failures).
      
      * Bug fix: missing `py::` for `py::ssize_t`
      
      * Restoring tuple(), list() ssize_t support, but passing `size` by value, for compatibility with older compilers (to resolve link failures).
      
      * Full test coverage of all functions with modified signatures.
      777352fc
  7. 26 Aug, 2021 6 commits
  8. 24 Aug, 2021 1 commit
  9. 19 Aug, 2021 2 commits
    • Liam Keegan's avatar
      ci: extend msys2 mingw CI (#3207) · 4f29b8a4
      Liam Keegan authored
      * extend msys2 CI
      
      - add 32-bit job
      - add c++11/17 c++/interface tests copied from standard ci
      - add numpy/scipy
      
      * account for padding of PartialStruct in numpy dtypes test with mingw32
      
      * [pre-commit.ci] auto fixes from pre-commit.com hooks
      
      for more information, see https://pre-commit.ci
      
      
      
      * msys2 ci: add c++14 tests
      Co-authored-by: default avatarpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
      4f29b8a4
    • Ralf W. Grosse-Kunstleve's avatar
      Cleanup of file-scoped and globally-scoped warning suppression pragmas across... · 998d45e4
      Ralf W. Grosse-Kunstleve authored
      Cleanup of file-scoped and globally-scoped warning suppression pragmas across pybind11 header files. (#3201)
      
      * Removing all MSVC C4127 warning suppression pragmas.
      
      * Removing MSVC /WX (WERROR). To get a full list of all warnings.
      
      * Inserting PYBIND11_SILENCE_MSVC_C4127. Changing one runtime if to #if.
      
      * Changing PYBIND11_SILENCE_MSVC_C4127 macro to use absolute namespace (for use outside pybind11 include directory).
      
      * Restoring MSVC /WX (WERROR).
      
      * Removing globally-scoped suppression for clang -Wunsequenced. Based on an experiment under PR #3202 it is obsolete and can simply be removed.
      998d45e4
  10. 13 Aug, 2021 1 commit
    • Aaron Gokaslan's avatar
      maint(precommit): Apply isort (#3195) · 9df2f1ff
      Aaron Gokaslan authored
      * Apply isort
      
      * Tweak isort config
      
      * Add env.py as a known_first_party
      
      * Add one missing known first party
      
      * Make config compat with older isort versions
      
      * Add another comment
      
      * Revert pyproject setting
      9df2f1ff
  11. 06 Aug, 2021 2 commits
    • Eric Cousineau's avatar
      test_eval: Show example of working closure (#2743) · 6ac8efe5
      Eric Cousineau authored
      
      
      * test_eval: Show example of working closure
      
      * Extend test_eval_closure with weirder examples of closures for py::eval
      Co-authored-by: default avatarYannick Jadoul <yannick.jadoul@belgacom.net>
      Co-authored-by: default avatarAaron Gokaslan <skylion.aaron@gmail.com>
      6ac8efe5
    • Aaron Gokaslan's avatar
      maint(clang-tidy): Bugprone enable checks (#3166) · 3893f37b
      Aaron Gokaslan authored
      * Enable bugprone checks
      
      * Reset delta and massage config
      
      * Start to apply bugprone fixes
      
      * try to fix minor bug
      
      * Fix later
      
      * Fix perfect forwarding bugprone
      
      * Remove nolint
      
      * undo constructor delete
      
      * Fix bugprone-perfect-forwarding again
      
      * Remove TODO
      
      * Add another nolint for bugprone-exception-escape in scoped interpreter
      
      * Fix remaining bugprone errors
      
      * Properly apply bugprone-macro-parantheses
      
      * Redo formatting and remove bugprone nolint
      
      * Add coment and revert more whitespace changes
      
      * Fix typo
      
      * Fix parsing bug
      
      * Add back comma
      
      * Fix clang-tidy issue
      
      * Apply remaining clang-tidy fixes
      3893f37b
  12. 30 Jul, 2021 1 commit
  13. 29 Jul, 2021 1 commit
  14. 27 Jul, 2021 4 commits
  15. 21 Jul, 2021 1 commit
    • jesse-sony's avatar
      Feature/local exception translator (#2650) · d65edfb0
      jesse-sony authored
      * Create a module_internals struct
      
      Since we now have two things that are going to be module local, it felt
      correct to add a struct to manage them.
      
      * Add local exception translators
      
      These are added via the  register_local_exception_translator function
      and are then applied before the global translators
      
      * Add unit tests to show the local exception translator works
      
      * Fix a bug in the unit test with the string value of KeyError
      
      * Fix a formatting issue
      
      * Rename registered_local_types_cpp()
      
      Rename it to get_registered_local_types_cpp() to disambiguate from the
      new member of module_internals
      
      * Add additional comments to new local exception code path
      
      * Add a register_local_exception function
      
      * Add additional unit tests for register_local_exception
      
      * Use get_local_internals like get_internals
      
      * Update documentation for new local exception feature
      
      * Add back a missing space
      
      * Clean-up some issues in the docs
      
      * Remove the code duplication when translating exceptions
      
      Separated out the exception processing into a standalone function in the
      details namespace.
      
      Clean-up some comments as per PR notes as well
      
      * Remove the code duplication in register_exception
      
      * Cleanup some formatting things caught by clang-format
      
      * Remove the templates from exception translators
      
      But I added a using declaration to alias the type.
      
      * Remove the extra local from local_internals variable names
      
      * Add an extra explanatory comment to local_internals
      
      * Fix a typo in the code
      d65edfb0
  16. 14 Jul, 2021 3 commits
  17. 13 Jul, 2021 4 commits
    • Antony Lee's avatar
      Add helper to build in-tree extensions. (#2831) · 1be0a0a6
      Antony Lee authored
      
      
      For single-file extensions, a convenient pattern offered by cython
      is to place the source files directly in the python source tree
      (`foo/__init__.py`, `foo/ext.pyx`), deriving the package names from
      their filesystem location.  Adapt this pattern for pybind11, using an
      `intree_extensions` helper, which should be thought of as the moral
      equivalent to `cythonize`.
      
      Differences with cythonize: I chose not to include globbing support
      (`intree_extensions(glob.glob("**/*.cpp"))` seems sufficient), nor to
      provide extension-customization kwargs (directly setting the attributes
      on the resulting Pybind11Extension objects seems sufficient).
      
      We could choose to have `intree_extension` (singular instead) and make
      users write `[*map(intree_extension, glob.glob("**/*.cpp"))]`; no strong
      opinion here.
      Co-authored-by: default avatarAaron Gokaslan <skylion.aaron@gmail.com>
      1be0a0a6
    • Aaron Gokaslan's avatar
      fix(clang-tidy): Add cppcoreguidelines-init-vars,slicing, and... · 25e470c5
      Aaron Gokaslan authored
      fix(clang-tidy): Add cppcoreguidelines-init-vars,slicing, and throw-by-value-catch-by-reference checks (#3094)
      
      * clang-tidy: guard against more UB behavior
      
      * Remove slicing check for now
      25e470c5
    • Henry Schreiner's avatar
      style: add pyupgrade check, 2.7+ · 0e2e0035
      Henry Schreiner authored
      0e2e0035
    • Henry Schreiner's avatar
      chore: update pre-commit hooks · 84fdadfb
      Henry Schreiner authored
      84fdadfb
  18. 12 Jul, 2021 3 commits
  19. 09 Jul, 2021 1 commit