Python 2.0 naive question

David Bolen db3l at
Fri Sep 22 08:13:25 CEST 2000

"Fredrik Lundh" <effbot at> writes:

> The problem is that the PYD files contains the name of the Python
> DLL they were linked against, so old PYDs will load the 1.5.2 DLL file,
> and call the wrong version of Py_InitModule.  This DLL isn't properly
> initialized, and Py_InitModule will crash.

Yes, the older Python DLL will load, but that shouldn't have to cause
a crash, should it?  Presumably, the PYD is calling Py_InitModule from
within its initXxxx function, but that initXxxx function is called
from Python explicitly.

So if Python first looks for a new export that only exists in the new
version, and aborts - as part of the import - if it doesn't find it,
it'll never call initXxxx in the 1.5.2 PYD and you avoid the crash.
If you make the new export a function that returns the Python version
the PYD was built with then Python just calls that (or aborts
immediately assuming pre-2.0 if it isn't exported) and checks it
against its own version - _before_ it calls the initXxxx function in
the PYD.

Or am I still missing something?  Crashing the whole process if you
accidentally get a 1.5.2 PYD lying around just seems really nasty.

-- David
 \               David Bolen            \   E-mail: db3l at  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \

More information about the Python-list mailing list