Skip to content

Missing complex types in cached btypes #110

Closed
@michalhabera

Description

@michalhabera

As of version 1.17.0 python3 -c "import cffi; ffi = cffi.FFI(); print(ffi.typeof('double _Complex'))"
gives me

root@150c1467a397:/home/dolfinx/python/demo# python3 -c "import cffi; ffi = cffi.FFI(); print(ffi.typeof('double _Complex'))"
Traceback (most recent call last):
  File "/dolfinx-env/lib/python3.12/site-packages/cffi/api.py", line 183, in _typeof
    result = self._parsed_types[cdecl]
             ~~~~~~~~~~~~~~~~~~^^^^^^^
KeyError: 'double _Complex'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/dolfinx-env/lib/python3.12/site-packages/cffi/api.py", line 437, in _get_cached_btype
    BType = self._cached_btypes[type]
            ~~~~~~~~~~~~~~~~~~~^^^^^^
KeyError: <_cffi_double_complex_t>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/dolfinx-env/lib/python3.12/site-packages/cffi/model.py", line 58, in get_cached_btype
    BType = ffi._cached_btypes[self]
            ~~~~~~~~~~~~~~~~~~^^^^^^
KeyError: <_cffi_double_complex_t>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/dolfinx-env/lib/python3.12/site-packages/cffi/api.py", line 200, in typeof
    return self._typeof(cdecl)
           ^^^^^^^^^^^^^^^^^^^
  File "/dolfinx-env/lib/python3.12/site-packages/cffi/api.py", line 186, in _typeof
    result = self._typeof_locked(cdecl)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/dolfinx-env/lib/python3.12/site-packages/cffi/api.py", line 175, in _typeof_locked
    btype = self._get_cached_btype(type)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/dolfinx-env/lib/python3.12/site-packages/cffi/api.py", line 440, in _get_cached_btype
    BType = type.get_cached_btype(self, finishlist)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/dolfinx-env/lib/python3.12/site-packages/cffi/model.py", line 60, in get_cached_btype
    BType = self.build_backend_type(ffi, finishlist)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/dolfinx-env/lib/python3.12/site-packages/cffi/model.py", line 175, in build_backend_type
    return global_cache(self, ffi, 'new_primitive_type', self.name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/dolfinx-env/lib/python3.12/site-packages/cffi/model.py", line 598, in global_cache
    res = getattr(ffi._backend, funcname)(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: '_cffi_double_complex_t'

while for 1.16.0 this worked. I've also noticed that CompiledFFI that has complex types declared does recognize complex types. Did complex types cache go missing with recent changes or is this behaviour on purpose (for Win platform compatibility)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions