Migrate PYD Files

Kay Schluehr kay.schluehr at gmx.net
Thu Sep 8 14:49:46 CEST 2005


David Duerrenmatt wrote:
> Is there a way to use old pyd files (Python 1.5.2) with a newer version
> of Python without recompiling them?
>
> Because the source code is not available anymore, I'm wondering whether
> it's possible or not to change few bytes with a hex editor (version
> number?). I'd like to give it a try since the modules don't use too
> critical functions.
>
> Thanks
> dd

Hi David,

you might checkout embedding your Python 1.5.2 interpreter into Python
using ctypes. Just follow chap.5 of the "Extending and Embedding"
tutorial and the docs of the cytpes API.

The following little script runs successfully on Python23 interpreter.

======================================================================

import ctypes
python24 = ctypes.cdll.LoadLibrary("python24.dll")
python24.Py_Initialize()
python24.PyRun_SimpleString("from time import time,ctime\n")
python24.PyRun_SimpleString("print 'Today is',ctime(time())\n");
python24.Py_Finalize()

Kay




More information about the Python-list mailing list