On Tue, Mar 24, 2015 at 11:31 PM, Paul Moore <p.f.mo...@gmail.com> wrote: > On 12 March 2015 at 17:44, Paul Moore <p.f.mo...@gmail.com> wrote: >> On 12 March 2015 at 17:26, Brett Cannon <br...@python.org> wrote: >>>> I'm all for ditching our 'libffi_msvc' in favor of adding libffi as >>>> another 'external' for the Windows build. I have managed to get >>>> _ctypes to build on Windows using vanilla libffi sources, prepared >>>> using their configure script from within Git Bash and built with our >>>> usual Windows build system (properly patched). Unfortunately, making >>>> things usable will take some work on ctypes itself, which I'm not >>>> qualified to do. I'm happy to pass on my procedure and patches for >>>> getting to the point of successful compilation to anyone who feels up >>>> to fixing the things that are broken. >>> >>> >>> So it seems possible to use upstream libffi but will require some work. >> >> I'd be willing to contemplate helping out on the Windows side of >> things, if nobody else steps up (with the proviso that I have little >> free time, and I'm saying this without much idea of what's involved >> :-)) If Zachary can give a bit more detail on what the work on ctypes >> is, and/or put what he has somewhere that I could have a look at, that >> might help. > > One thing that seems to be an issue. On Windows, ctypes detects if the > FFI call used the wrong number of arguments off the stack, and raises > a ValueError if it does. The tests rely on that behaviour. But it's > based on ffi_call() returning a value, which upstream libffi doesn't > do. As far as I can tell (not that the libffi docs are exactly > comprehensive...) there's no way of getting that information from > upstream libffi. > > What does Unix ctypes do when faced with a call being made with the > wrong number of arguments? On Windows, using upstream libffi and > omitting the existing check, it seems to crash the Python process, > which obviously isn't good. But the test that fails is > Windows-specific, and short of going through all the tests looking for > one that checks passing the wrong number of arguments and isn't > platform-specific, I don't know how Unix handles this. > > Can anyone on Unix tell me if a ctypes call with the wrong number of > arguments returns ValueError on Unix? Something like strcmp() (with no > args) should do as a test, I guess... > > If there's a way Unix handles this, I can see about replicating it on > Windows. But if there isn't, I fear we could always need a patched > libffi to maintain the interface we currently have... > > Thanks, > Paul
Linux crashes. The mechanism for detecting the number of arguments is only available on windows (note that this is a band-aid anyway, since if your arguments are of the wrong kind you segfault anyway). We do have two copies of libffi one for windows one for unix anyway, don't we? _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com