Unable to cast Python instance to C++ type - using clang
I tried to test the python bindings using clang-10 on debian-11. I followed the "first approach" described on the homepage to setup the environment. Whenever i tried to generate a class I got a error message like this:
>>> from dune.common import FieldVector
>>> fv = FieldVector([1.0])
Traceback (most recent call last):
File "/home/nils/workbench/dune-python/dune-common/build-cmake/python/dune/common/__init__.py", line 57, in FieldVector
return globals()[fv](values)
KeyError: 'FieldVector_1'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/nils/workbench/dune-python/dune-common/build-cmake/python/dune/common/__init__.py", line 61, in FieldVector
cls = loadvec(includes, typeName).FieldVector
File "/home/nils/workbench/dune-python/dune-common/build-cmake/python/dune/common/__init__.py", line 51, in loadvec
return generatorvec.load(includes ,typeName ,typeHash,
File "/home/nils/workbench/dune-python/dune-common/build-cmake/python/dune/generator/generator.py", line 159, in load
return self.post(moduleName, source)
File "/home/nils/workbench/dune-python/dune-common/build-cmake/python/dune/generator/generator.py", line 117, in post
module = builder.load(moduleName, source, self.typeName[0])
File "/home/nils/workbench/dune-python/dune-common/build-cmake/python/dune/generator/builder.py", line 179, in load
module = importlib.import_module("dune.generated." + moduleName)
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 565, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 1108, in create_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
ImportError: Unable to cast Python instance to C++ type (compile in debug mode for details)
Compiling in debug-mode ("-DCMAKE_BUILD_TYPE=Debug") does not yield any details. Does anybody know what is actually meant by "debug mode"?
Switching to gcc solves the problem.
It seems that the exception is thrown by pybind11 in cast.h:1699 .
Edited by Nils-Arne Dreier