Skip to content

Commit 4928b03

Browse files
committed
Merge branch 'master' into sh_merge_master
2 parents 18fae43 + 5bc0943 commit 4928b03

28 files changed

+671
-104
lines changed

.github/ISSUE_TEMPLATE/bug-report.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ body:
66
- type: markdown
77
attributes:
88
value: |
9-
Maintainers will only make a best effort to triage PRs. Please do your best to make the issue as easy to act on as possible, and only open if clearly a problem with pybind11 (ask first if unsure).
9+
Please do your best to make the issue as easy to act on as possible, and only submit here if there is clearly a problem with pybind11 (ask first if unsure). **Note that a reproducer in a PR is much more likely to get immediate attention.**
10+
1011
- type: checkboxes
1112
id: steps
1213
attributes:
@@ -20,6 +21,12 @@ body:
2021
- label: Consider asking first in the [Gitter chat room](https://gitter.im/pybind/Lobby) or in a [Discussion](https:/pybind/pybind11/discussions/new).
2122
required: false
2223

24+
- type: Input
25+
id: version
26+
attributes:
27+
label: What version (or hash if on master) of pybind11 are you using?
28+
required: true
29+
2330
- type: textarea
2431
id: description
2532
attributes:
@@ -40,6 +47,14 @@ body:
4047
The code should be minimal, have no external dependencies, isolate the
4148
function(s) that cause breakage. Submit matched and complete C++ and
4249
Python snippets that can be easily compiled and run to diagnose the
43-
issue. If possible, make a PR with a new, failing test to give us a
44-
starting point to work on!
50+
issue. — Note that a reproducer in a PR is much more likely to get
51+
immediate attention: failing tests in the pybind11 CI are the best
52+
starting point for working out fixes.
4553
render: text
54+
55+
- type: Input
56+
id: regression
57+
attributes:
58+
label: Is this a regression? Put the last known working version here if it is.
59+
description: Put the last known working version here if this is a regression.
60+
value: Not a regression

.github/workflows/ci.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- '3.6'
3232
- '3.9'
3333
- '3.10'
34-
- '3.11-dev'
34+
- '3.11'
3535
- 'pypy-3.7'
3636
- 'pypy-3.8'
3737
- 'pypy-3.9'
@@ -103,10 +103,12 @@ jobs:
103103
run: python -m pip install pytest-github-actions-annotate-failures
104104

105105
# First build - C++11 mode and inplace
106+
# More-or-less randomly adding -DPYBIND11_SIMPLE_GIL_MANAGEMENT=ON here.
106107
- name: Configure C++11 ${{ matrix.args }}
107108
run: >
108109
cmake -S . -B .
109110
-DPYBIND11_WERROR=ON
111+
-DPYBIND11_SIMPLE_GIL_MANAGEMENT=ON
110112
-DDOWNLOAD_CATCH=ON
111113
-DDOWNLOAD_EIGEN=ON
112114
-DCMAKE_CXX_STANDARD=11
@@ -120,7 +122,7 @@ jobs:
120122

121123
- name: C++11 tests
122124
# TODO: Figure out how to load the DLL on Python 3.8+
123-
if: "!(runner.os == 'Windows' && (matrix.python == 3.8 || matrix.python == 3.9 || matrix.python == '3.10' || matrix.python == '3.11-dev' || matrix.python == 'pypy-3.8'))"
125+
if: "!(runner.os == 'Windows' && (matrix.python == 3.8 || matrix.python == 3.9 || matrix.python == '3.10' || matrix.python == '3.11' || matrix.python == 'pypy-3.8'))"
124126
run: cmake --build . --target cpptest -j 2
125127

126128
- name: Interface test C++11
@@ -130,10 +132,12 @@ jobs:
130132
run: git clean -fdx
131133

132134
# Second build - C++17 mode and in a build directory
135+
# More-or-less randomly adding -DPYBIND11_SIMPLE_GIL_MANAGEMENT=OFF here.
133136
- name: Configure C++17
134137
run: >
135138
cmake -S . -B build2
136139
-DPYBIND11_WERROR=ON
140+
-DPYBIND11_SIMPLE_GIL_MANAGEMENT=OFF
137141
-DDOWNLOAD_CATCH=ON
138142
-DDOWNLOAD_EIGEN=ON
139143
-DCMAKE_CXX_STANDARD=17
@@ -147,7 +151,7 @@ jobs:
147151

148152
- name: C++ tests
149153
# TODO: Figure out how to load the DLL on Python 3.8+
150-
if: "!(runner.os == 'Windows' && (matrix.python == 3.8 || matrix.python == 3.9 || matrix.python == '3.10' || matrix.python == '3.11-dev' || matrix.python == 'pypy-3.8'))"
154+
if: "!(runner.os == 'Windows' && (matrix.python == 3.8 || matrix.python == 3.9 || matrix.python == '3.10' || matrix.python == '3.11' || matrix.python == 'pypy-3.8'))"
151155
run: cmake --build build2 --target cpptest
152156

153157
# Third build - C++17 mode with unstable ABI
@@ -187,7 +191,7 @@ jobs:
187191
- python-version: "3.9"
188192
python-debug: true
189193
valgrind: true
190-
- python-version: "3.11-dev"
194+
- python-version: "3.11"
191195
python-debug: false
192196

193197
name: "🐍 ${{ matrix.python-version }}${{ matrix.python-debug && '-dbg' || '' }} (deadsnakes)${{ matrix.valgrind && ' • Valgrind' || '' }} • x64"
@@ -392,7 +396,7 @@ jobs:
392396
# Testing on CentOS 7 + PGI compilers, which seems to require more workarounds
393397
centos-nvhpc7:
394398
runs-on: ubuntu-latest
395-
name: "🐍 3 • CentOS7 / PGI 22.3 • x64"
399+
name: "🐍 3 • CentOS7 / PGI 22.9 • x64"
396400
container: centos:7
397401

398402
steps:
@@ -402,7 +406,7 @@ jobs:
402406
run: yum update -y && yum install -y epel-release && yum install -y git python3-devel make environment-modules cmake3 yum-utils
403407

404408
- name: Install NVidia HPC SDK
405-
run: yum-config-manager --add-repo https://developer.download.nvidia.com/hpc-sdk/rhel/nvhpc.repo && yum -y install nvhpc-22.3
409+
run: yum-config-manager --add-repo https://developer.download.nvidia.com/hpc-sdk/rhel/nvhpc.repo && yum -y install nvhpc-22.9
406410

407411
# On CentOS 7, we have to filter a few tests (compiler internal error)
408412
# and allow deeper template recursion (not needed on CentOS 8 with a newer
@@ -412,12 +416,12 @@ jobs:
412416
shell: bash
413417
run: |
414418
source /etc/profile.d/modules.sh
415-
module load /opt/nvidia/hpc_sdk/modulefiles/nvhpc/22.3
419+
module load /opt/nvidia/hpc_sdk/modulefiles/nvhpc/22.9
416420
cmake3 -S . -B build -DDOWNLOAD_CATCH=ON \
417421
-DCMAKE_CXX_STANDARD=11 \
418422
-DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") \
419423
-DCMAKE_CXX_FLAGS="-Wc,--pending_instantiations=0" \
420-
-DPYBIND11_TEST_FILTER="test_smart_ptr.cpp;test_virtual_functions.cpp"
424+
-DPYBIND11_TEST_FILTER="test_smart_ptr.cpp"
421425
422426
# Building before installing Pip should produce a warning but not an error
423427
- name: Build

.github/workflows/labeler.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ jobs:
1010
steps:
1111

1212
- uses: actions/labeler@main
13-
if: github.event.pull_request.merged == true
13+
if: >
14+
github.event.pull_request.merged == true &&
15+
!startsWith(github.event.pull_request.title, 'chore(deps):') &&
16+
!startsWith(github.event.pull_request.title, 'ci(fix):') &&
17+
!startsWith(github.event.pull_request.title, 'docs(changelog):')
1418
with:
1519
repo-token: ${{ secrets.GITHUB_TOKEN }}
1620
configuration-path: .github/labeler_merged.yml

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,16 @@ endif()
9191
option(PYBIND11_INSTALL "Install pybind11 header files?" ${PYBIND11_MASTER_PROJECT})
9292
option(PYBIND11_TEST "Build pybind11 test suite?" ${PYBIND11_MASTER_PROJECT})
9393
option(PYBIND11_NOPYTHON "Disable search for Python" OFF)
94+
option(PYBIND11_SIMPLE_GIL_MANAGEMENT
95+
"Use simpler GIL management logic that does not support disassociation" OFF)
9496
set(PYBIND11_INTERNALS_VERSION
9597
""
9698
CACHE STRING "Override the ABI version, may be used to enable the unstable ABI.")
9799

100+
if(PYBIND11_SIMPLE_GIL_MANAGEMENT)
101+
add_compile_definitions(PYBIND11_SIMPLE_GIL_MANAGEMENT)
102+
endif()
103+
98104
cmake_dependent_option(
99105
USE_PYTHON_INCLUDE_DIR
100106
"Install pybind11 headers in Python include directory instead of default installation prefix"

docs/changelog.rst

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,104 @@ IN DEVELOPMENT
1616

1717
Changes will be summarized here periodically.
1818

19+
Version 2.10.1 (Oct 2?, 2022)
20+
-----------------------------
21+
22+
23+
Changes:
24+
25+
26+
* Allow ``pybind11::capsule`` constructor to take null destructor pointers.
27+
`#4221 <https://github.com/pybind/pybind11/pull/4221>`_
28+
29+
* ``embed.h`` was changed so that ``PYTHONPATH`` is used also with Python 3.11
30+
(established behavior).
31+
`#4119 <https://github.com/pybind/pybind11/pull/4119>`_
32+
33+
Bug fixes:
34+
35+
* Fix MSVC 2019 v.1924 & C++14 mode error for ``overload_cast``.
36+
`#4188 <https://github.com/pybind/pybind11/pull/4188>`_
37+
38+
* Make augmented assignment operators non-const for the object-api. Behavior
39+
was previously broken for augmented assignment operators.
40+
`#4065 <https://github.com/pybind/pybind11/pull/4065>`_
41+
42+
* Add proper error checking to C++ bindings for Python list append and insert.
43+
`#4208 <https://github.com/pybind/pybind11/pull/4208>`_
44+
45+
* Work-around for Nvidia's CUDA nvcc compiler in versions 11.4.0 - 11.8.0.
46+
`#4220 <https://github.com/pybind/pybind11/pull/4220>`_
47+
48+
* A workaround for PyPy was added in the ``py::error_already_set``
49+
implementation, related to PR `#1895 <https://github.com/pybind/pybind11/pull/1895>`_
50+
released with v2.10.0.
51+
`#4079 <https://github.com/pybind/pybind11/pull/4079>`_
52+
53+
* Fixed compiler errors when C++23 ``std::forward_like`` is available.
54+
`#4136 <https://github.com/pybind/pybind11/pull/4136>`_
55+
56+
* Properly raise exceptions in contains methods (like when an object in unhashable).
57+
`#4209 <https://github.com/pybind/pybind11/pull/4209>`_
58+
59+
* Further improve another error in exception handling.
60+
`#4232 <https://github.com/pybind/pybind11/pull/4232>`_
61+
62+
* ``get_local_internals()`` was made compatible with
63+
``finalize_interpreter()``, fixing potential freezes during interpreter
64+
finalization.
65+
`#4192 <https://github.com/pybind/pybind11/pull/4192>`_
66+
67+
68+
Performance and style:
69+
70+
* Reserve space in set and STL map casters if possible. This will prevent
71+
unnecessary rehashing / resizing by knowing the number of keys ahead of time
72+
for Python to C++ casting. This improvement will greatly speed up the casting
73+
of large unordered maps and sets.
74+
`#4194 <https://github.com/pybind/pybind11/pull/4194>`_
75+
76+
* GIL RAII scopes are non-copyable to avoid potential bugs.
77+
`#4183 <https://github.com/pybind/pybind11/pull/4183>`_
78+
79+
* Explicitly default all relevant ctors for pytypes in the ``PYBIND11_OBJECT``
80+
macros and enforce the clang-tidy checks ``modernize-use-equals-default`` in
81+
macros as well.
82+
`#4017 <https://github.com/pybind/pybind11/pull/4017>`_
83+
84+
* Optimize iterator advancement in C++ bindings.
85+
`#4237 <https://github.com/pybind/pybind11/pull/4237>`_
86+
87+
* Use the modern ``PyObject_GenericGetDict`` and ``PyObject_GenericSetDict``
88+
for handling dynamic attribute dictionaries.
89+
`#4106 <https://github.com/pybind/pybind11/pull/4106>`_
90+
91+
* Document that users should use ``PYBIND11_NAMESPACE`` instead of using ``pybind11`` when
92+
opening namespaces. Using namespace declarations and namespace qualification
93+
remain the same as ``pybind11``. This is done to ensure consistent symbol
94+
visibility.
95+
`#4098 <https://github.com/pybind/pybind11/pull/4098>`_
96+
97+
* Mark ``detail::forward_like`` as constexpr.
98+
`#4147 <https://github.com/pybind/pybind11/pull/4147>`_
99+
100+
* Optimize unpacking_collector when processing ``arg_v`` arguments.
101+
`#4219 <https://github.com/pybind/pybind11/pull/4219>`_
102+
103+
104+
Build system improvements:
105+
106+
* Include a pkg-config file when installing pybind11, such as in the Python
107+
package.
108+
`#4077 <https://github.com/pybind/pybind11/pull/4077>`_
109+
110+
* Avoid stripping debug symbols when ``CMAKE_BUILD_TYPE`` is set to ``DEBUG``
111+
instead of ``Debug``.
112+
`#4078 <https://github.com/pybind/pybind11/pull/4078>`_
113+
114+
* Followup to `#3948 <https://github.com/pybind/pybind11/pull/3948>`_, fixing vcpkg again.
115+
`#4123 <https://github.com/pybind/pybind11/pull/4123>`_
116+
19117
Version 2.10.0 (Jul 15, 2022)
20118
-----------------------------
21119

include/pybind11/cast.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ struct void_caster {
278278
return false;
279279
}
280280
static handle cast(T, return_value_policy /* policy */, handle /* parent */) {
281-
return none().inc_ref();
281+
return none().release();
282282
}
283283
PYBIND11_TYPE_CASTER(T, const_name("None"));
284284
};
@@ -321,7 +321,7 @@ class type_caster<void> : public type_caster<void_type> {
321321
if (ptr) {
322322
return capsule(ptr).release();
323323
}
324-
return none().inc_ref();
324+
return none().release();
325325
}
326326

327327
template <typename T>
@@ -571,7 +571,7 @@ struct type_caster<CharT, enable_if_t<is_std_char_type<CharT>::value>> {
571571

572572
static handle cast(const CharT *src, return_value_policy policy, handle parent) {
573573
if (src == nullptr) {
574-
return pybind11::none().inc_ref();
574+
return pybind11::none().release();
575575
}
576576
return StringCaster::cast(StringType(src), policy, parent);
577577
}
@@ -1220,11 +1220,9 @@ enable_if_t<cast_is_temporary_value_reference<T>::value, T> cast_safe(object &&)
12201220
pybind11_fail("Internal error: cast_safe fallback invoked");
12211221
}
12221222
template <typename T>
1223-
enable_if_t<std::is_same<void, intrinsic_t<T>>::value, void> cast_safe(object &&) {}
1223+
enable_if_t<std::is_void<T>::value, void> cast_safe(object &&) {}
12241224
template <typename T>
1225-
enable_if_t<detail::none_of<cast_is_temporary_value_reference<T>,
1226-
std::is_same<void, intrinsic_t<T>>>::value,
1227-
T>
1225+
enable_if_t<detail::none_of<cast_is_temporary_value_reference<T>, std::is_void<T>>::value, T>
12281226
cast_safe(object &&o) {
12291227
return pybind11::cast<T>(std::move(o));
12301228
}

include/pybind11/detail/common.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,8 @@
205205
# endif
206206
#endif
207207

208-
#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
209-
# define PYBIND11_HAS_U8STRING
210-
#endif
211-
212208
#include <Python.h>
209+
// Reminder: WITH_THREAD is always defined if PY_VERSION_HEX >= 0x03070000
213210
#if PY_VERSION_HEX < 0x03060000
214211
# error "PYTHON < 3.6 IS UNSUPPORTED. pybind11 v2.9 was the last to support Python 2 and 3.5."
215212
#endif
@@ -233,6 +230,10 @@
233230
# undef copysign
234231
#endif
235232

233+
#if defined(PYPY_VERSION) && !defined(PYBIND11_SIMPLE_GIL_MANAGEMENT)
234+
# define PYBIND11_SIMPLE_GIL_MANAGEMENT
235+
#endif
236+
236237
#if defined(_MSC_VER)
237238
# if defined(PYBIND11_DEBUG_MARKER)
238239
# define _DEBUG
@@ -259,6 +260,11 @@
259260
# endif
260261
#endif
261262

263+
// Must be after including <version> or one of the other headers specified by the standard
264+
#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
265+
# define PYBIND11_HAS_U8STRING
266+
#endif
267+
262268
// #define PYBIND11_STR_LEGACY_PERMISSIVE
263269
// If DEFINED, pybind11::str can hold PyUnicodeObject or PyBytesObject
264270
// (probably surprising and never documented, but this was the

0 commit comments

Comments
 (0)