[Python-Dev] SSL support in _socket

Tim Peters tim.one@comcast.net
Sat, 16 Feb 2002 22:41:53 -0500

> Side-note: I've added the "inter-module dynamic C API linking
> via Python trick" from the mx tools to the _socket module. _ssl
> only uses it to get at the type object, but the support can easily
> be extended if this should be needed for more C APIs from
> _socket.
> Also note: the non-Unix build process files need to be updated.

I don't know what "inter-module dynamic C API linking via Python trick"
means, but the Windows build doesn't compile anymore despite that it didn't
and doesn't support SSL.  I suspect it's because "inter-module" wrt sockets
is really "cross-DLL" on Windows, and clever tricks are going to bite hard
because of that.  It's griping here:

static PyTypeObject PySocketSock_Type = {
C:\Code\python\Modules\socketmodule.c(1768) : error C2491:
    'PySocketSock_Type' : definition of dllimport data not allowed

and here:

C:\Code\python\Modules\socketmodule.c(2650) : error C2099:
    initializer is not a constant

The changes to socketmodule.h pretty much baffle me.  Why is the body of the
function PySocketModule_ImportModuleAndAPI included in the header file?  Why
is the body of this function skipped unless PySocket_BUILDING_SOCKET is
defined?  All in all, this appears to be an extremely confusing way to
define a function named PySocketModule_ImportModuleAndAPI in the new _ssl.c
alone.  So why isn't the function just defined in _ssl.c directly?  There
appears no reason to put it in the header file, and it's confusing there.

This shows signs of adapting a complicated framework to a situation too
simple to require most of what the framework does.  If so, since there is no
other use of this framework in Python, and the framework isn't documented in
the Python codebase, the framework should be tossed, and something as simple
as possible done instead.

I can't make more time to sort this out now.  It would help if the code were
made more transparent (see last paragraph), so it consumed less time to
figure out what it's intending to do.  In the meantime, the Windows build
will remain broken.