Skip to content

Commit 8736e1a

Browse files
committed
Resolve long-standing using module_def = PyModuleDef; // TODO: Can this be removed
The TODO was introduced with: 7800e7f
1 parent c4346e3 commit 8736e1a

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

include/pybind11/detail/common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,15 @@
366366
PYBIND11_WARNING_PUSH
367367
PYBIND11_WARNING_DISABLE_CLANG("-Wgnu-zero-variadic-macro-arguments")
368368
#define PYBIND11_MODULE_PYINIT(name, pre_init, ...) \
369-
static ::pybind11::module_::module_def PYBIND11_CONCAT(pybind11_module_def_, name); \
369+
static PyModuleDef PYBIND11_CONCAT(pybind11_module_def_, name); \
370370
static ::pybind11::module_::slots_array PYBIND11_CONCAT(pybind11_module_slots_, name); \
371371
static int PYBIND11_CONCAT(pybind11_exec_, name)(PyObject *); \
372372
static void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ &); \
373373
PYBIND11_PLUGIN_IMPL(name) { \
374374
PYBIND11_CHECK_PYTHON_VERSION \
375375
pre_init; \
376376
PYBIND11_ENSURE_INTERNALS_READY \
377-
static auto def = []() { \
377+
static PyModuleDef *def = []() { \
378378
auto &slots = PYBIND11_CONCAT(pybind11_module_slots_, name); \
379379
slots[0] = {Py_mod_exec, \
380380
reinterpret_cast<void *>(&PYBIND11_CONCAT(pybind11_exec_, name))}; \

include/pybind11/pybind11.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,16 +1438,14 @@ class module_ : public object {
14381438
PyModule_AddObject(ptr(), name, obj.inc_ref().ptr() /* steals a reference */);
14391439
}
14401440

1441-
using module_def = PyModuleDef; // TODO: Can this be removed (it was needed only for Python 2)?
1442-
14431441
/** \rst
14441442
Create a new top-level module that can be used as the main module of a C extension.
14451443
14461444
``def`` should point to a statically allocated module_def.
14471445
\endrst */
14481446
static module_ create_extension_module(const char *name,
14491447
const char *doc,
1450-
module_def *def,
1448+
PyModuleDef *def,
14511449
mod_gil_not_used gil_not_used
14521450
= mod_gil_not_used(false)) {
14531451
// module_def is PyModuleDef
@@ -1491,11 +1489,11 @@ class module_ : public object {
14911489
additional slots from the supplied options (and the empty sentinel slot).
14921490
\endrst */
14931491
template <typename... Options>
1494-
static module_def *initialize_multiphase_module_def(const char *name,
1495-
const char *doc,
1496-
module_def *def,
1497-
slots_array &slots,
1498-
Options &&...options) {
1492+
static PyModuleDef *initialize_multiphase_module_def(const char *name,
1493+
const char *doc,
1494+
PyModuleDef *def,
1495+
slots_array &slots,
1496+
Options &&...options) {
14991497
size_t next_slot = 0;
15001498
size_t term_slot = slots.size() - 1;
15011499

tests/test_modules.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ TEST_SUBMODULE(modules, m) {
7878
class DupeException {};
7979

8080
// Go ahead and leak, until we have a non-leaking py::module_ constructor
81-
auto dm
82-
= py::module_::create_extension_module("dummy", nullptr, new py::module_::module_def);
81+
auto dm = py::module_::create_extension_module("dummy", nullptr, new PyModuleDef);
8382
auto failures = py::list();
8483

8584
py::class_<Dupe1>(dm, "Dupe1");

0 commit comments

Comments
 (0)