11/*
2- tests/test_local_bindings.cpp -- tests the py::local class feature which makes a class binding
3- local to the module in which it is defined.
2+ tests/test_local_bindings.cpp -- tests the py::module_local class feature which makes a class
3+ binding local to the module in which it is defined.
44
55 Copyright (c) 2017 Jason Rhinelander <[email protected] > 66
1515TEST_SUBMODULE (local_bindings, m) {
1616
1717 // test_local_bindings
18- // Register a class with py::local :
19- bind_local<LocalType, -1 >(m, " LocalType" , py::local ())
18+ // Register a class with py::module_local :
19+ bind_local<LocalType, -1 >(m, " LocalType" , py::module_local ())
2020 .def (" get3" , [](LocalType &t) { return t.i + 3 ; })
2121 ;
2222
@@ -31,28 +31,28 @@ TEST_SUBMODULE(local_bindings, m) {
3131 ;
3232
3333 // test_duplicate_local
34- // py::local declarations should be visible across compilation units that get linked together;
34+ // py::module_local declarations should be visible across compilation units that get linked together;
3535 // this tries to register a duplicate local. It depends on a definition in test_class.cpp and
3636 // should raise a runtime error from the duplicate definition attempt. If test_class isn't
3737 // available it *also* throws a runtime error (with "test_class not enabled" as value).
3838 m.def (" register_local_external" , [m]() {
3939 auto main = py::module::import (" pybind11_tests" );
4040 if (py::hasattr (main, " class_" )) {
41- bind_local<LocalExternal, 7 >(m, " LocalExternal" , py::local ());
41+ bind_local<LocalExternal, 7 >(m, " LocalExternal" , py::module_local ());
4242 }
4343 else throw std::runtime_error (" test_class not enabled" );
4444 });
4545
4646 // test_stl_bind_local
47- // stl_bind.h binders defaults to py::local :
47+ // stl_bind.h binders defaults to py::module_local :
4848 py::bind_vector<std::vector<LocalType>>(m, " LocalVec" );
4949 py::bind_vector<std::vector<NonLocalType>>(m, " LocalVec2" );
5050 py::bind_map<std::unordered_map<std::string, LocalType>>(m, " LocalMap" );
5151 py::bind_map<std::unordered_map<std::string, NonLocalType>>(m, " LocalMap2" );
5252
5353 // test_stl_bind_global
54- // They can, however, be overridden to global using `py::local (false)`:
54+ // They can, however, be overridden to global using `py::module_local (false)`:
5555 bind_local<NonLocal2, 10 >(m, " NonLocal2" );
56- py::bind_vector<std::vector<NonLocal2>>(m, " NonLocalVec" , py::local (false ));
57- py::bind_map<std::unordered_map<std::string, NonLocal2>>(m, " NonLocalMap" , py::local (false ));
56+ py::bind_vector<std::vector<NonLocal2>>(m, " NonLocalVec" , py::module_local (false ));
57+ py::bind_map<std::unordered_map<std::string, NonLocal2>>(m, " NonLocalMap" , py::module_local (false ));
5858}
0 commit comments