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

Trent Mick trentm@activestate.com
Fri, 2 Jun 2000 13:10:58 -0700


On Fri, Jun 02, 2000 at 09:45:25PM +0200, Peter Funk wrote:
> Hi,
> 
> Trent Mick:
> [...]
> > PyMarshal_WriteLongToFile your long is truncated to 32-bits. However, if you
> > write a long indirectly by PyMarshal_WriteObjectToFile, where that Python
> > object is or contains a PyInt (C long), then the long is *not* truncated.
> > 
> > Options:
> > 
> > 1. leave it, who cares
> > 
> > 2. - change PyMarshal_WriteLongToFile to write 64-bits if long is 64-bits
> >    - add something like PyMarshal_WriteInt32ToFile for the benefit of users
> > 	 like import.c that want to control exactly how many bytes get written
> > 
> > 3. - change PyMarshal_WriteLongToFile to raise an exception if the long
> > 	 overflows a 32-bit range
> 
> We should try to achieve the following goal:  .pyc files should be portable
> from 32 bit systems to 64 bit systems and vice versa.  This means 
> always truncating to 32 bits and raising an exception, if an overflow
> occurs.  
>
Or offer PyMarshal_WriteInt32ToFile for import.c and import.c itself can do
the overflow checking on the time stamp. That is the RIght THing(TM) IMO.

Anyway, my question was intended to be more about the subtlety of marshal
functions rather than the .pyc file headers. No question that the .pyc's
should be portable.

Trent
-- 
Trent Mick
trentm@activestate.com