18 static const char *
report_status() {
return enabled ?
"guarded" :
"unguarded"; }
28 static const char *
report_status() {
return enabled ?
"guarded" :
"unguarded"; }
38 Child() {
py::print(
"Allocating child."); }
39 Child(
const Child &) =
default;
40 Child(Child &&) =
default;
41 ~Child() {
py::print(
"Releasing child."); }
48 Parent() {
py::print(
"Allocating parent."); }
49 ~Parent() {
py::print(
"Releasing parent."); }
50 void addChild(Child *) { }
51 Child *returnChild() {
return new Child(); }
52 Child *returnNullChild() {
return nullptr; }
57 .def(
"addChild", &Parent::addChild)
59 .
def(
"returnChild", &Parent::returnChild)
64 #if !defined(PYPY_VERSION) 66 class ParentGC :
public Parent {
78 m.
def(
"multiple_guards_correct_order", []() {
82 m.
def(
"multiple_guards_wrong_order", []() {
86 #if defined(WITH_THREAD) && !defined(PYPY_VERSION) 89 auto report_gil_status = []() {
90 auto is_gil_held =
false;
92 is_gil_held = (tstate == PyGILState_GetThisThreadState());
94 return is_gil_held ?
"GIL held" :
"GIL released";
97 m.
def(
"with_gil", report_gil_status);
test_initializer call_policies("call_policies", test_submodule_call_policies)
PyThreadState * get_thread_state_unchecked()
Annotation which enables dynamic attributes, i.e. adds __dict__ to a class.
static const char * report_status()
detail::initimpl::constructor< Args... > init()
Binds an existing constructor taking arguments Args...
Keep patient alive while nurse lives.
static const char * report_status()
void print(Args &&...args)
#define TEST_SUBMODULE(name, variable)
bool typename Extra class_ & def(const char *name_, Func &&f, const Extra &... extra)