@@ -8,6 +8,47 @@ to a new version. But it goes into more detail. This includes things like
8
8
deprecated APIs and their replacements, build system changes, general code
9
9
modernization and other useful information.
10
10
11
+ .. _upgrade-guide-2.7 :
12
+
13
+ v2.7
14
+ ====
15
+
16
+ The previously-deprecated constructor of ``py::module_ `` now creates a Python
17
+ module object that is *not * used as the top-level module of a C extension.
18
+ Previous usage of the deprecated ``PYBIND11_PLUGIN `` macro using the constructor
19
+ instead of ``py::module_::create_extension_module `` will result in the following error
20
+ on import: ``SystemError: initialization of example did not return an extension module ``.
21
+
22
+ In this case, change the following doubly-deprecated, memory-leaking pattern:
23
+
24
+ .. code-block :: cpp
25
+
26
+ PYBIND11_PLUGIN(example) {
27
+ auto m = pybind11::module_("example", "pybind11 example plugin");
28
+ /// Set up bindings here
29
+ return m.ptr();
30
+ }
31
+
32
+ into this:
33
+
34
+ .. code-block :: cpp
35
+
36
+ static pybind11::module_::module_def example_module_def;
37
+ PYBIND11_PLUGIN(example) {
38
+ auto m = pybind11::module_::create_extension_module(
39
+ "example", "pybind11 example plugin", &example_module_def);
40
+ /// Set up bindings here
41
+ return m.ptr();
42
+ }
43
+
44
+ or, preferably, avoid the deprecated ``PYBIND11_PLUGIN `` completely:
45
+
46
+ .. code-block :: cpp
47
+
48
+ PYBIND11_MODULE(example, m) {
49
+ /// Set up bindings here
50
+ }
51
+
11
52
.. _upgrade-guide-2.6 :
12
53
13
54
v2.6
0 commit comments