* 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.
* Use equivalent_integer for enum's Scalar decision
* Add test for char underlying enum
* Support translating bool type in enum's Scalar
* Add test for bool underlying enum
* Fix comment in test
* Switch from `PYBIND11_CPP20` macro to `PYBIND11_HAS_U8STRING`
* Refine tests
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
* Call PySys_SetArgv when initializing interpreter.
* Document argc/argv parameters in initialize_interpreter.
* Remove manual memory management from set_interpreter_argv in favor of smart pointers.
* Use size_t for indexers in set_interpreter_argv.
* Minimize macros for flow control in set_interpreter_argv.
* Fix 'unused variable' warning on Py2
* whitespace
* Define wide_char_arg_deleter outside set_interpreter_argv.
* Do sys.path workaround in C++ rather than eval.
* Factor out wchar conversion to a separate function.
* Restore widened_argv variable declaration.
* Fix undeclared widened_arg variable on some paths.
* Use delete[] to match new wchar_t[].
* Fix compiler errors
* Use PY_VERSION_HEX for a cleaner CVE-2008-5983 mode check.
* Fix typo
* Use explicit type for deleter so delete[] works cross-compiler.
* Always use PySys_SetArgvEx because pybind11 doesn't support pythons that don't include it.
* Remove pointless ternary operator.
* Use unique_ptr.reset instead of a second initialization.
* Rename add_program_dir_to_path parameter to clarify intent.
* Add defined() check before evaluating HAVE_BROKEN_MBSTOWCS.
* Apply clang-tidy fixes
* Pre-commit
* refactor: use const for set_interpreter_argv
* Try to fix const issue and allocate vector properly
* fix: copy strings on Python 2
* Applying clang-format-diff relative to master.
The only manual change is an added empty line between pybind11 and system `#include`s.
```
git diff -U0 --no-color master | python3 $HOME/clone/llvm-project/clang/tools/clang-format/clang-format-diff.py -p1 -style=file -i
```
Co-authored-by: Boris Staletic <boris.staletic@gmail.com>
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
* Add py::raise_from to enable chaining exceptions on Python 3.3+
* Use 'raise from' in initialization
* Documenting the exact base version of _PyErr_FormatVFromCause, adding back `assert`s.
Co-authored-by: Dustin Spicuzza <dustin@virtualroadside.com>
* 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: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* 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.
The only manual intervention was to remove the merge conflict markers in pybind11.h.
TODO in separate commit: complete removal of the obsolete detail/pragma_warning_block.h.
* 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
* test_eval: Show example of working closure
* Extend test_eval_closure with weirder examples of closures for py::eval
Co-authored-by: Yannick Jadoul <yannick.jadoul@belgacom.net>
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
* mingw64 platform string is like mingw_xxx not "mingw"
See https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-python/0099-Change-the-get_platform-method-in-sysconfig-and-dist.patch
* Mingw: Do not dllexport exceptions
This is a fix for errors like:
D:/a/pybind11/pybind11/include/pybind11/detail/common.h:735:23: error: 'dllexport' implies default visibility, but 'class pybind11::builtin_exception' has already been declared with a different visibility
735 | class PYBIND11_EXPORT builtin_exception : public std::runtime_error {
| ^~~~~~~~~~~~~~~~~
* GHA: Test Mingw64 build
* fix: avoid thin binaries on mingw
* fix: drop lto on MinGW
* Mingw64: disable PYBIND11_DEPRECATED
It trigger many warnings for unknown reasons
Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
* Fixing `pragma warning pop` for `__INTEL_COMPILER`.
* Adding push/pop to 3 tests. Removing #878 from top of pybind11.h (it was/is only needed for 1 test).
* Trying again after CI failure, moving the push to the top of 2 tests.
* Trying more after CI failure, adding push/pop to pybind11_tests.h, constructor_stats.h.
* Moving ICC #2196 suppression to CMakeLists.txt
* Fixing condition for `pragma GCC diagnostic push` in pybind11.h
* Moving `pragma warning disable 2196` to common.h
* Revising #ifdef to be more conservative.
* Undoing insertion of notes that will hopefully soon be completely obsolete anyway.
* maint(clang-tidy) Improve code readability
* Fix minor typos
* Revert optimization that removed test case
* Fix comment formatting
* Revert another optimization to repro an issue
* Remove make_unique since it C++14 and newer only
* eformat comments
* Fix unsignedness of comparison
* Update comment
* Allow python builtins to be used as callbacks
* Try to fix pypy segfault
* Add expected fail for PyPy
* Fix typo
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add more info to xfail
* Add env
* Try returning false
* Try removing the move for pypy
* Fix bugs
* Try removing move
* Just keep ignoring for PyPy
* Add back xfail
* Fix ctors
* Revert change of std::move
* Change to skip
* Fix bug and edit comments
* Remove clang-tidy bugprone fix skip bug
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>
* 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
* Raise codec errors when casting to std::string
Allow the codec's exception to be raised instead of RuntimeError when
casting from py::str to std::string.
PY2 allows ucs surrogates in UTF-8 conversion
Signed-off-by: Shane Loretz <sloretz@openrobotics.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
* Attempt to fix py2 error
* Revert all unicode literals
* Fixed
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
* Manually moving `// NOLINT` comments so that clang-format does not move them to the wrong places.
* Manually reformatting comments related to `static_assert`s so that clang-format does not need two passes.
* Empty lines between #includes, to prevent clang-format from shuffling the order and thereby confusing MSVC 2015.
* git diff -U0 --no-color HEAD^ | python3 $HOME/clone/llvm-project/clang/tools/clang-format/clang-format-diff.py -p1 -style=file -i
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: Aaron Gokaslan <skylion.aaron@gmail.com>
* Adding test_return_vector_bool_raw_ptr to test_stl.py.
* First attempt to make the documentation more accurate, but not trying to be comprehensive, to not bloat the reference table with too many details.
* Fixing minor oversights.
* Applying reviewer suggestion.
* Adding iostream.h thread-safety documentation.
* Restoring `TestThread` code with added `std::lock_guard<std::mutex>`.
* Updating new comments to reflect new information.
* Fixing up `git rebase -X theirs` accidents.