When release_GIL_and_enable_signal is switched on, the result object is created inside a nested try block (line 547 of wrap.cxx). Later, it is assumed to be visible in the enclosing scope of that try (line 563).
|
try { |
|
${overload._get_calling_pattern1()} |
|
%if overload.release_GIL_and_enable_signal : |
|
PyOS_sighandler_t sig = PyOS_getsig(SIGINT); |
|
cpp2py::signal_handler::start(); // start the C++ signal handler |
|
Py_BEGIN_ALLOW_THREADS; |
|
try { |
|
%endif |
|
${overload._get_calling_pattern()}; // the call is here. It sets up "result" : sets up in the python layer. |
|
%if overload.release_GIL_and_enable_signal : |
|
} |
|
catch(...) { |
|
// an error has occurred : clean GIL, handler and rethrow |
|
Py_BLOCK_THREADS; // cf python include, ceval.h, line 72 comments and below. |
|
cpp2py::signal_handler::stop(); // stop the C++ signal handler |
|
PyOS_setsig(SIGINT, sig); |
|
throw; // |
|
} |
|
Py_END_ALLOW_THREADS; |
|
cpp2py::signal_handler::stop(); |
|
PyOS_setsig(SIGINT, sig); |
|
%endif |
|
%if not overload.is_constructor : |
|
%if overload.rtype != "void" : |
|
py_result = convert_to_python(std::move(result)); |
|
%else: |
|
Py_INCREF(Py_None); |
|
py_result = Py_None; |
|
%endif |
|
%endif |
|
return ${'py_result' if not py_meth.is_constructor else '0'}; |
|
} |
I wanted to prepare a minimal example based on an existing wrapping unit test, but those seem to have been disabled in both TRIQS unstable and cpp2py.
When
release_GIL_and_enable_signalis switched on, theresultobject is created inside a nestedtryblock (line 547 ofwrap.cxx). Later, it is assumed to be visible in the enclosing scope of thattry(line 563).cpp2py/cpp2py/mako/wrap.cxx
Lines 539 to 570 in a54c236
I wanted to prepare a minimal example based on an existing wrapping unit test, but those seem to have been disabled in both TRIQS
unstableand cpp2py.