@@ -40,20 +40,15 @@ unmarshalling. Version 2 uses a binary format for floating point numbers.
40
40
41
41
The following functions allow marshalled values to be read back in.
42
42
43
- XXX What about error detection? It appears that reading past the end of the
44
- file will always result in a negative numeric value (where that's relevant),
45
- but it's not clear that negative values won't be handled properly when there's
46
- no error. What's the right way to tell? Should only non-negative values be
47
- written using these routines?
48
-
49
43
50
44
.. c :function :: long PyMarshal_ReadLongFromFile (FILE *file)
51
45
52
46
Return a C :c:type: `long ` from the data stream in a :c:type: `FILE\* ` opened
53
47
for reading. Only a 32-bit value can be read in using this function,
54
48
regardless of the native size of :c:type: `long `.
55
49
56
- On error, raise an exception and return ``-1 ``.
50
+ On error, sets the appropriate exception (:exc: `EOFError `) and returns
51
+ ``-1``.
57
52
58
53
59
54
.. c:function:: int PyMarshal_ReadShortFromFile(FILE *file)
@@ -62,16 +57,17 @@ written using these routines?
62
57
for reading. Only a 16-bit value can be read in using this function,
63
58
regardless of the native size of :c:type: `short `.
64
59
65
- On error, raise an exception and return ``-1 ``.
60
+ On error, sets the appropriate exception (:exc: `EOFError `) and returns
61
+ ``-1``.
66
62
67
63
68
64
.. c:function:: PyObject* PyMarshal_ReadObjectFromFile(FILE *file)
69
65
70
66
Return a Python object from the data stream in a :c:type: `FILE\* ` opened for
71
67
reading.
72
68
73
- On error, sets the appropriate exception (:exc: `EOFError ` or
74
- :exc: `TypeError `) and returns *NULL*.
69
+ On error, sets the appropriate exception (:exc: `EOFError `, :exc: ` ValueError `
70
+ or :exc: `TypeError `) and returns *NULL*.
75
71
76
72
77
73
.. c:function:: PyObject* PyMarshal_ReadLastObjectFromFile(FILE *file)
@@ -84,15 +80,15 @@ written using these routines?
84
80
file. Only use these variant if you are certain that you won't be reading
85
81
anything else from the file.
86
82
87
- On error, sets the appropriate exception (:exc: `EOFError ` or
88
- :exc: `TypeError `) and returns *NULL*.
83
+ On error, sets the appropriate exception (:exc: `EOFError `, :exc: ` ValueError `
84
+ or :exc: `TypeError `) and returns *NULL*.
89
85
90
86
91
87
.. c:function:: PyObject* PyMarshal_ReadObjectFromString(const char *data, Py_ssize_t len)
92
88
93
89
Return a Python object from the data stream in a byte buffer
94
90
containing *len * bytes pointed to by *data *.
95
91
96
- On error, sets the appropriate exception (:exc: `EOFError ` or
97
- :exc: `TypeError `) and returns *NULL*.
92
+ On error, sets the appropriate exception (:exc: `EOFError `, :exc: ` ValueError `
93
+ or :exc: `TypeError `) and returns *NULL*.
98
94
0 commit comments