[Python-Dev] PyMarshal_WriteLongToFile: writes 'long' or 32-bit integer?
Trent Mick
trentm@activestate.com
Fri, 2 Jun 2000 11:14:17 -0700
So, is PyMarshal_WriteLongToFile intended to write a C long, regardless of
its size, or is it intended to alway write 32-bits?
Currently it just writes 32-bits and if sizeof(long) > 4 for that platform
then it is silently truncated. PyMarshal_WriteLongToFile is currently only
used (in the core anyway) to write the magic number and timestamp for .pyc
files in import.c.
The current situation is pretty misleading. If you write a long directly with
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
Thanks,
Trent
--
Trent Mick
trentm@activestate.com