[Python-Dev] PyMarshal_WriteLongToFile: writes 'long' or 32-bit integer?

Peter Funk pf@artcom-gmbh.de
Tue, 6 Jun 2000 11:05:58 +0200 (MEST)


Hi,

[Trent Mick]:
[...]
> - PyMarshal_WriteObjectToFile, when writing a PyInt and hence a C long, will
>   *NOT* truncate the 64-bit integer but will write the whole thing
> 
> - On reading a .pyc the PyMarshal_ReadObjectFromFile will complain on stderr
>   when a 64-bit integral value is read and the current platform is 32-bit.
[...]
> The question is: Do we want PyMarshal_WriteLongToFile *AND*
> PyMarshal_WriteObjectToFile to raise an exception when a long value overflows
> 32-bits? Up til now I was only proposing the former.

Yes.  This should at least be the default behaviour of Python.

The current behaviour would otherwise cause great damage in the
following scenario, where an innocent software developer working on
a 64-Bit system trusts on the cross platform portability of Pythons
bytecode files and unintentional uses a huge integer literal.

If some people really don't care about portability, there could be 
switch/option/pragma/whatever to disable this behaviour.

IMO the portability of Python bytecode files is a *very* valuable property,
which we shouldn't give up on.

Regards, Peter