[Python-Dev] Where is PyMarshal_ReadShortFromFile() ? (original) (raw)

James C. Ahlstrom jim@interet.com
Fri, 12 Oct 2001 09:45:39 -0400


"Fred L. Drake, Jr." wrote:

James C. Ahlstrom writes: > Yes, I think PyMarshalReadLongFromFile() and PyMarshalReadShortFromFile() > are indeed part of Python's public C API, and that is why they were in > marshal.c with public declarations. I think my "should they be?" question remains valid.

Ooops, I meant "they were in marshal.h".

Yes they should be public, because PyMarshal_ReadLongFromFile() is used in import.c to read the Python byte code signature MAGIC from a *.pyc file. I need a PyMarshal_ReadShortFromFile() to read zip archives in import.c.

Modules/testcapimodule.c.

Thanks, I knew it had to be somewhere but I couldn't find it.

If the function is being sufficiently covered by other tests, then we don't need to add new tests. Since it was missing, I have to presume it wasn't being called. That tells me that it either isn't needed at all or some test needs to exercise it.

Not true. PyMarshal_ReadLongFromFile() is just a wraper function for the function r_long() which is used internally by marshal. Similarly, there is already an r_short() used internally by marshal. Presumably, marshal would't work if these fail, so I assume they work. The PyMarshal_ReadShortFromFile() is just a wraper for r_short(), not new funtionality.

As for the documentation, I think the discoverability issue I brought up indicates that we're doing the right thing -- its a lot easier to learn the public API with documentation than without it. I don't know about the rest of the PythonLabs group, but I certainly find the C API documentaiton useful.

Yes, I find it essential, and wish there were more.

JimA