[Python-Dev] PyMarshal_WriteLongToFile: writes 'long' or 32-bit integer?
Trent Mick
trentm@activestate.com
Mon, 5 Jun 2000 17:14:03 -0700
On Sat, Jun 03, 2000 at 10:56:15AM +0300, Moshe Zadka wrote:
> On Fri, 2 Jun 2000, Trent Mick wrote:
>
> > 3. - change PyMarshal_WriteLongToFile to raise an exception if the long
> > overflows a 32-bit range
>
> +1 on that, finally non-portable integers will cause an exception.
>
Okay, I have to reiterate and ask again because I have the suspicion that I
may be missing the point and you all may not realize that. Stop me when I go
astray:
- the PyMarshal interface is used for all the .pyc content writing
- PyMarshal_WriteLongToFile is only used for writing the magic number and the
time stamp
- the rest of the .pyc is written via PyMarshal_WriteObjectToFile
- PyMarshal_WriteLongToFile will currently silently truncate a 64-bit long to
32-bits
- 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.
Trent
--
Trent Mick
trentm@activestate.com