Re: Using ctypes inside a C application embedding the CPython runtime

eryk sun <[email protected]> Wed, 8 Jun 2016 03:36:13 +0000
Newsgroups gmane.comp.python.ctypes
Message-ID <CACL+1ashbR6eiTPTfcW0PY0t+TUC60uAwt_4M2h_1uLBU0-L+w@mail.gmail.com>
On Tue, Jun 7, 2016 at 10:06 PM, [email protected]
<[email protected]> wrote:
>
> If filename is NULL, then the returned handle is for the main
>        program.  When given to dlsym(), this handle causes a search for a
>        symbol in the main program, followed by all shared objects loaded at
>        program startup, and then all shared objects loaded by dlopen() with
>        the flag RTLD_GLOBAL.
>
> As documented on dlopen's manpage[1], and this is working right now. What
> we're worried about is that passing None to the CDLL constructor is not
> documented anywhere (at least that I could find), so we're not sure if we
> can rely on this functionality (if so, the documentation should probably be
> updated and I can help with that if needed) or if there's an alternate
> recommended and documented way of achieving the same result.

This should have been documented for POSIX systems, which rely on this
feature internally for `pythonapi = PyDLL(None)`.

Of course, Windows LoadLibrary doesn't accept NULL, so CDLL(None) is
an error there. It could be special cased as GetModuleHandle(NULL),
but that's rarely useful in this context since there's no global
symbol table.

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e