Using marshal to manually "import" a python module

"Martin v. Löwis" martin at
Fri Nov 30 07:58:53 CET 2007

> The strange thing is, it worked fine locally on my two machines (32bit
> running python 2.3.5 and 64bit running python 2.4.1), but when run by a
> 64bit machine on the network, it would fail every time in the following
> manner:

It may not that much be an issue of 32-bit vs. 64-bit, but of Python 2.3
vs. Python 2.4. The marshal format changes across versions, and files
created in one version might not be understood correctly by another version.

Now, you don't give enough details on resolving this completely: what
specific microprocessors, and what specific operating systems are you
using? What is the specific code of the module that fails to load (e.g.
minimal example), and what is the resulting byte code?

Off-hand, I can't see why a 2.3-generated file shouldn't be loadable
by a 2.4 interpreter, but you say "it" fails without saying what "it"
is (i.e. running the 64-bit machine to generate a marshal file over
the net that is then read by the 32-bit machine, or vice versa).

> I can't figure out why this would work locally, but not when the module
> is loaded across a network. In fact, I have no idea what would ever
> cause it not to see A as a function. I'm stumped, and this is over my
> head as far as intimate knowledge of the direct loading of python
> bytecode via marshal is I'm not clear on the best way to
> debug it.

I would trace through the loading, either in a debugger, or by adding
printf statements into marshal.


More information about the Python-list mailing list