PySide generates Interface files by introspection. The generator is used in the build process since 5.12.1 .
By running a build with python 3.5, we now experience a crash in the build system, since generate_pyi.py creates a segfault. When running the build again with the option "--reuse-build", it seems to work. But actually the script is not run at all because the first run could not remove its lock directory.
Running a Python trace, the crash could be located in the file contextlib.py, which is used heavily by enumerating the PySide functions and types. The top-level functions are correctly generated, but when Python enters the context of
Replacing this module by a newer version (Python 3.6 ands Python 3.7 tested), the problem goes away. But now, a crash happens in the finalization code of PySide.
PySide generates a function called cleanTypesAttributes for every class, that is called when the class shuts down. When Python 3.5 calls this function on the testbinding module, is creates a segfault. It was impossible to circumvent this segfault. Example:
This error could only prevented by skipping this code. Even the PyObject_HasAttrString call causes the crash, already.
This problem looks first like a pure Python 3.5 bug that newer versions do not have. It can be circumvented by replacing contextlib.py.
The second problem does only exist in the testbinding module, which indicates that something is wrong with it, too. Removing the cleanTypesAttributes does not really harm on shutdown, but the problem is therefore circumvented but not solved.
This problem could creep into our codebase unrecognized, because we do not test multiple Python versions automatically, yet. We should improve this.