Creating multiple ffi/lib instances with the same symbols leads to trouble

Issue #116 closed
Alex Gaynor
created an issue
import cffi

def make_ffi_lib():
    ffi = cffi.FFI()
    typedef struct {
    } FOO_T;

    void f(FOO_T *);
    lib = ffi.verify("""
    typedef struct {
    } FOO_T;

    void f(FOO_T *f) {
    return ffi, lib

ffi1, lib1 = make_ffi_lib()
f1 ="FOO_T *")

ffi2, lib2 = make_ffi_lib()
f2 ="FOO_T *")


Results in:

(71050223369f0860) /tmp $ python
Traceback (most recent call last):
  File "", line 27, in <module>
TypeError: initializer for ctype 'FOO_T *' must be a pointer to same type, not cdata 'FOO_T *'

But only under CPython, under PyPy it runs fine.

Comments (3)

  1. Armin Rigo

    It's messy to implement without changing the whole world. I've tried a few times but give up for now, and replaced it with giving out a warning when you try to re-import the same .so.

  2. Log in to comment