Skip to content

Commit 9be4fa3

Browse files
committed
tests/python: use old-style call to parent ctor
1 parent 43022a1 commit 9be4fa3

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

unittest/bind_virtual_factory.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct MyVirtualClass {
2424
};
2525

2626
struct MyVirtualData {
27-
MyVirtualData(MyVirtualClass const&) {}
27+
MyVirtualData(MyVirtualClass const &) {}
2828
virtual ~MyVirtualData() {} // virtual dtor to mark class as polymorphic
2929
};
3030

@@ -84,8 +84,9 @@ struct VirtualClassWrapper : MyVirtualClass, bp::wrapper<MyVirtualClass> {
8484
/// This "trampoline class" does nothing but is ABSOLUTELY required to ensure
8585
/// downcasting works properly with non-smart ptr signatures. Otherwise,
8686
/// there is no handle to the original Python object ( @c PyObject *).
87-
/// Every single polymorphic type exposed to Python should be exposed through such a trampoline.
88-
/// Users can also create their own wrapper classes by taking inspiration from boost::python::wrapper<T>.
87+
/// Every single polymorphic type exposed to Python should be exposed through
88+
/// such a trampoline. Users can also create their own wrapper classes by taking
89+
/// inspiration from boost::python::wrapper<T>.
8990
struct DataWrapper : MyVirtualData, bp::wrapper<MyVirtualData> {
9091
/// we have to use-declare non-defaulted constructors
9192
/// (see https://en.cppreference.com/w/cpp/language/default_constructor)
@@ -99,7 +100,8 @@ const MyVirtualData &iden_ref(const MyVirtualData &d) {
99100
return d;
100101
}
101102

102-
/// Take a shared_ptr (by const reference or value, doesn't matter), return by const reference
103+
/// Take a shared_ptr (by const reference or value, doesn't matter), return by
104+
/// const reference
103105
const MyVirtualData &iden_shared(const shared_ptr<MyVirtualData> &d) {
104106
// get boost.python's custom deleter
105107
// boost.python hides the handle to the original object in there
@@ -136,7 +138,7 @@ BOOST_PYTHON_MODULE(bind_virtual_factory) {
136138
/// otherwise if passed as "HeldType", we need to define
137139
/// the constructor and call initializer manually.
138140
bp::class_<DataWrapper, boost::noncopyable>("MyVirtualData", bp::no_init)
139-
.def(bp::init<MyVirtualClass const&>(bp::args("self", "model")));
141+
.def(bp::init<MyVirtualClass const &>(bp::args("self", "model")));
140142

141143
bp::def("callDoSomethingPtr", callDoSomethingPtr, bp::args("obj"));
142144
bp::def("callDoSomethingRef", callDoSomethingRef, bp::args("obj"));

unittest/python/test_bind_virtual.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
class ImplClass(bvf.MyVirtualClass):
55
def __init__(self):
66
self.val = 42
7-
super().__init__()
7+
bvf.MyVirtualClass.__init__(self)
88

99
def createData(self):
1010
return ImplData(self)
@@ -27,7 +27,8 @@ def doSomethingRef(self, data):
2727

2828
class ImplData(bvf.MyVirtualData):
2929
def __init__(self, c):
30-
super().__init__(c) # parent virtual class requires arg
30+
# parent virtual class requires arg
31+
bvf.MyVirtualData.__init__(self, c)
3132
self.value = c.val
3233

3334

0 commit comments

Comments
 (0)