Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6a318d4

Browse files
committed
Issue #19428: Document that PyMarshal_ReadLongFromFile() and
PyMarshal_ReadShortFromFile() can fail.
1 parent d6dc7bd commit 6a318d4

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

Doc/c-api/marshal.rst

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,24 @@ written using these routines?
5353
for reading. Only a 32-bit value can be read in using this function,
5454
regardless of the native size of :c:type:`long`.
5555
56+
On error, raise an exception and return ``-1``.
57+
5658
5759
.. c:function:: int PyMarshal_ReadShortFromFile(FILE *file)
5860
5961
Return a C :c:type:`short` from the data stream in a :c:type:`FILE\*` opened
6062
for reading. Only a 16-bit value can be read in using this function,
6163
regardless of the native size of :c:type:`short`.
6264
65+
On error, raise an exception and return ``-1``.
66+
6367
6468
.. c:function:: PyObject* PyMarshal_ReadObjectFromFile(FILE *file)
6569
6670
Return a Python object from the data stream in a :c:type:`FILE\*` opened for
67-
reading. On error, sets the appropriate exception (:exc:`EOFError` or
71+
reading.
72+
73+
On error, sets the appropriate exception (:exc:`EOFError` or
6874
:exc:`TypeError`) and returns *NULL*.
6975
7076
@@ -76,14 +82,17 @@ written using these routines?
7682
aggressively load file data into memory so that the de-serialization can
7783
operate from data in memory rather than reading a byte at a time from the
7884
file. Only use these variant if you are certain that you won't be reading
79-
anything else from the file. On error, sets the appropriate exception
80-
(:exc:`EOFError` or :exc:`TypeError`) and returns *NULL*.
85+
anything else from the file.
86+
87+
On error, sets the appropriate exception (:exc:`EOFError` or
88+
:exc:`TypeError`) and returns *NULL*.
8189
8290
8391
.. c:function:: PyObject* PyMarshal_ReadObjectFromString(char *string, Py_ssize_t len)
8492
8593
Return a Python object from the data stream in a character buffer
86-
containing *len* bytes pointed to by *string*. On error, sets the
87-
appropriate exception (:exc:`EOFError` or :exc:`TypeError`) and returns
88-
*NULL*.
94+
containing *len* bytes pointed to by *string*.
95+
96+
On error, sets the appropriate exception (:exc:`EOFError` or
97+
:exc:`TypeError`) and returns *NULL*.
8998

0 commit comments

Comments
 (0)