Commit Graph

2389 Commits

Author SHA1 Message Date
Henry Schreiner
1fafd1b447
fix: apply simpler expression with fewer workarounds 2021-08-06 13:03:26 -04:00
Henry Schreiner
5f4d725918
fix: version number hex 2021-08-03 17:03:11 -04:00
Henry Schreiner
c30f57d2ed
chore: start development for 2.8.0 2021-08-03 16:11:07 -04:00
Henry Schreiner
787d2c88ca fix: include hex version in bump 2021-08-03 15:20:50 -04:00
Henry Schreiner
82adacb31d
fix: include hex version in bump 2021-08-03 15:20:23 -04:00
Henry Schreiner
5f34c42d70 chore: bump to version 2.7.1 2021-08-03 15:06:57 -04:00
Henry Schreiner
078c116749
chore: bump to version 2.7.1 2021-08-03 15:05:54 -04:00
Henry Schreiner
9095984850 chore: changelog update (#3163)
* chore: changelog update

* Update docs/changelog.rst
2021-08-03 13:17:14 -04:00
Aaron Gokaslan
9f204a1857 fix: func_handle for rule of two (#3169)
* Fix func_handle for rule of two

* Apply reviewer suggestion
2021-08-03 13:17:03 -04:00
pre-commit-ci[bot]
ada6b79104 [pre-commit.ci] pre-commit autoupdate (#3167)
updates:
- [github.com/asottile/pyupgrade: v2.23.0 → v2.23.1](https://github.com/asottile/pyupgrade/compare/v2.23.0...v2.23.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-08-03 13:16:54 -04:00
Henry Schreiner
a2b78a8c27
chore: changelog update (#3163)
* chore: changelog update

* Update docs/changelog.rst
2021-08-03 13:16:14 -04:00
Aaron Gokaslan
c0756ccd93
fix: func_handle for rule of two (#3169)
* Fix func_handle for rule of two

* Apply reviewer suggestion
2021-08-03 13:15:48 -04:00
pre-commit-ci[bot]
f4f4632e28
[pre-commit.ci] pre-commit autoupdate (#3167)
updates:
- [github.com/asottile/pyupgrade: v2.23.0 → v2.23.1](https://github.com/asottile/pyupgrade/compare/v2.23.0...v2.23.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-08-03 10:56:57 -04:00
Ralf W. Grosse-Kunstleve
dcbda8d7ff
Removing MSVC C4127 from pragma block at the top of pybind11.h (#3152)
* Removing pragma for 4127 (to see what is still broken with the latest code).

* Using new constexpr_bool() to suppress warning C4127.

* One missed case, Python 2 only.

* PYBIND11_SILENCE_MSVC_C4127 (more similar to the approach for C4100).
2021-07-30 11:25:29 -07:00
Ralf W. Grosse-Kunstleve
b961ac644f Moving pragma for MSVC warning C4505 from pybind11.h to existing list in detail/common.h (#3160)
* Moving pragma for C4505 from pybind11.h to existing list in detail/common.h.

* Removing 4 existing suppressions to 1. see what is still needed and 2. capture the MSVC messages.

* It turns out none of the 4 pragmas are needed anymore.
2021-07-30 13:58:24 -04:00
Jerome Robert
c80e059345 fix: Mingw64 corrected and add a CI job to test it (#3132)
* 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>
2021-07-30 13:58:16 -04:00
Ralf W. Grosse-Kunstleve
46c51fc03b Limiting pragma for ignoring GCC 7 -Wnoexcept-type to the scope of pybind11.h. (#3161)
* Moving pragma for ignoring -Wnoexcept-type to the one location where it is needed.

* Trying a second location.

* The previous commit worked (GitHub Actions green), but see the added comment about the dicy nature of -Wnoexcept-type ("if and only if").

* Applying reviewer suggestion.
2021-07-30 13:58:04 -04:00
Ralf W. Grosse-Kunstleve
e2573dc961
Moving pragma for MSVC warning C4505 from pybind11.h to existing list in detail/common.h (#3160)
* Moving pragma for C4505 from pybind11.h to existing list in detail/common.h.

* Removing 4 existing suppressions to 1. see what is still needed and 2. capture the MSVC messages.

* It turns out none of the 4 pragmas are needed anymore.
2021-07-30 10:51:50 -07:00
Jerome Robert
9e8a741baa
fix: Mingw64 corrected and add a CI job to test it (#3132)
* 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>
2021-07-30 13:48:41 -04:00
Ralf W. Grosse-Kunstleve
b42597291f
Limiting pragma for ignoring GCC 7 -Wnoexcept-type to the scope of pybind11.h. (#3161)
* Moving pragma for ignoring -Wnoexcept-type to the one location where it is needed.

* Trying a second location.

* The previous commit worked (GitHub Actions green), but see the added comment about the dicy nature of -Wnoexcept-type ("if and only if").

* Applying reviewer suggestion.
2021-07-30 07:09:55 -07:00
Henry Schreiner
b1fdbe6954
chore: add discussions link (#3159) 2021-07-29 16:10:18 -07:00
Ralf W. Grosse-Kunstleve
05852fb6bc
Accommodating environments that define __STDC_WANT_LIB_EXT1__ even if __STDC_LIB_EXT1__ is not defined by the implementation. (#3151)
Follow-on to PR #3129.
2021-07-28 21:49:10 -04:00
Ralf W. Grosse-Kunstleve
ed5fb66bd7
Removing __INTEL_COMPILER section from pragma block at the top of pybind11.h (#3135)
* 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.
2021-07-28 21:49:10 -04:00
Aaron Gokaslan
0ac4c8afd6
maint(clang-tidy): Improve code readability with explicit boolean casts (#3148)
* 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
2021-07-28 21:49:09 -04:00
Henry Schreiner
5c6bdb7215
fix: the CMake config in Python package had a hard coded path (#3144) 2021-07-28 21:49:09 -04:00
David Hewitt
fd71bd486d
Allow python builtins to be used as callbacks (#1413)
* 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>
2021-07-28 21:49:09 -04:00
Ralf W. Grosse-Kunstleve
e93d94594b
Removing MSVC C4800 from pragma block at the top of pybind11.h (#3141)
* Adding PYBIND11_COMPAT_BOOL_CAST to appease MSVC 2015 warning C4800.

* Replacing PYBIND11_COMPAT_BOOL_CAST with simpler != 0

* Extra parentheses (almost all compilers failed without these).
2021-07-28 21:49:09 -04:00
pre-commit-ci[bot]
c973660d6c
[pre-commit.ci] pre-commit autoupdate (#3143)
updates:
- [github.com/asottile/pyupgrade: v2.21.2 → v2.23.0](https://github.com/asottile/pyupgrade/compare/v2.21.2...v2.23.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-07-28 21:49:09 -04:00
Ralf W. Grosse-Kunstleve
85b38c69de
Adding pragma warning(disable: 4522) for MSVC <= 2017. (#3142) 2021-07-28 21:49:09 -04:00
Ralf W. Grosse-Kunstleve
b193d42c32
Removing MSVC C4996 from pragma block at the top of pybind11.h (#3129)
* Removing MSVC C4996 from pragma block at the top of pybind11.h

* localtime_thread_safe, PYBIND11_COMPAT_STRDUP

* Adding #include <ctime> (attempt to fix MSVC 2015, 2017 errors).
2021-07-28 21:49:06 -04:00
ka-bo
ee3ecb8ae2
Specified encoding in setup.py calls of open() (#3137)
* Specified encoding in setup.py calls of open()

* Fix for Python2

Co-authored-by: Karsten Bock <karsten.bock@dlr.de>
2021-07-28 21:48:08 -04:00
Henry Schreiner
c14b193308
chore: increase CMake upper limit (#3124) 2021-07-28 18:04:14 -07:00
Ralf W. Grosse-Kunstleve
b72ca7d1bd
Removing MSVC C4100 from pragma block at the top of pybind11.h (#3150)
* Removing pragma for 4100 (to see what is still broken with the latest code).

* Adding --keep-going

* Revert "Adding --keep-going"

This reverts commit 1c844c6ffd07a6111b644811e7e3b0a50b9d44bb.

* Introducing PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100.

* _MSC_VER <= 1916

* Replacing simple variadic function with variadic template (attempt to resolve MSVC 2017 failures).

* Preserving existing comment (moved from pybind11.h to detail/common.h).

* Adding blank lines for readability.
2021-07-28 17:01:21 -07:00
Ralf W. Grosse-Kunstleve
f4721a7b44
Accommodating environments that define __STDC_WANT_LIB_EXT1__ even if __STDC_LIB_EXT1__ is not defined by the implementation. (#3151)
Follow-on to PR #3129.
2021-07-28 08:58:36 -07:00
Ralf W. Grosse-Kunstleve
2164c2e0e7
Removing __INTEL_COMPILER section from pragma block at the top of pybind11.h (#3135)
* 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.
2021-07-27 15:33:31 -07:00
Aaron Gokaslan
9beaa925db
maint(clang-tidy): Improve code readability with explicit boolean casts (#3148)
* 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
2021-07-27 15:32:26 -07:00
Henry Schreiner
7cc0ebb475
fix: the CMake config in Python package had a hard coded path (#3144) 2021-07-27 17:23:52 -04:00
David Hewitt
a0b975965f
Allow python builtins to be used as callbacks (#1413)
* 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>
2021-07-27 14:16:28 -04:00
Ralf W. Grosse-Kunstleve
a0f862d428
Removing MSVC C4800 from pragma block at the top of pybind11.h (#3141)
* Adding PYBIND11_COMPAT_BOOL_CAST to appease MSVC 2015 warning C4800.

* Replacing PYBIND11_COMPAT_BOOL_CAST with simpler != 0

* Extra parentheses (almost all compilers failed without these).
2021-07-26 13:26:36 -07:00
pre-commit-ci[bot]
7f76d79508
[pre-commit.ci] pre-commit autoupdate (#3143)
updates:
- [github.com/asottile/pyupgrade: v2.21.2 → v2.23.0](https://github.com/asottile/pyupgrade/compare/v2.21.2...v2.23.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-07-26 15:05:58 -04:00
Ralf W. Grosse-Kunstleve
7904ba1a5c
Adding pragma warning(disable: 4522) for MSVC <= 2017. (#3142) 2021-07-26 12:02:50 -07:00
Ralf W. Grosse-Kunstleve
ff97f101d9
Removing MSVC C4996 from pragma block at the top of pybind11.h (#3129)
* Removing MSVC C4996 from pragma block at the top of pybind11.h

* localtime_thread_safe, PYBIND11_COMPAT_STRDUP

* Adding #include <ctime> (attempt to fix MSVC 2015, 2017 errors).
2021-07-26 11:28:36 -07:00
ka-bo
e58c6897cc
Specified encoding in setup.py calls of open() (#3137)
* Specified encoding in setup.py calls of open()

* Fix for Python2

Co-authored-by: Karsten Bock <karsten.bock@dlr.de>
2021-07-21 12:00:57 -04:00
jesse-sony
d65edfb024
Feature/local exception translator (#2650)
* 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
2021-07-21 05:22:18 -07:00
blacktea
6d5d4e738c
Move object in pop method of List. (#3116)
* Move item instead of copy.

* Make Clang 3.6 happy.

Co-authored-by: c99 <email@dummy.com>
2021-07-20 11:48:09 -04:00
pre-commit-ci[bot]
9626483cdf
[pre-commit.ci] pre-commit autoupdate (#3134)
updates:
- [github.com/asottile/pyupgrade: v2.21.0 → v2.21.2](https://github.com/asottile/pyupgrade/compare/v2.21.0...v2.21.2)
- [github.com/psf/black: 21.6b0 → 21.7b0](https://github.com/psf/black/compare/21.6b0...21.7b0)
- https://gitlab.com/pycqa/flake8https://github.com/PyCQA/flake8
2021-07-20 11:29:42 -04:00
Ralf W. Grosse-Kunstleve
34f587dd23
Removing all warning pragmas that have not effect. (#3127) 2021-07-17 08:54:31 -07:00
Henry Schreiner
74935f8d67
chore: post-release (#3128) 2021-07-17 11:50:42 -04:00
Henry Schreiner
65e95ea867
chore: bump to 2.7.0 (#3123) 2021-07-16 09:27:47 -04:00
Henry Schreiner
6642f389dc
docs: update changelog (#3122) 2021-07-15 20:00:07 -04:00