]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.10] gh-105184: document that marshal functions can fail and need to be checked...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 5 Jun 2023 16:06:43 +0000 (09:06 -0700)
committerGitHub <noreply@github.com>
Mon, 5 Jun 2023 16:06:43 +0000 (18:06 +0200)
(cherry picked from commit ee26ca13a129da8cf549409d0a1b2e892ff2b4ec)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Doc/c-api/marshal.rst
Python/marshal.c

index 8e25968c6909fd69650f04f2811d9a26c4c56b09..489f1580a414b2d7c4514b878c68a5f65e2ee377 100644 (file)
@@ -25,12 +25,16 @@ unmarshalling.  Version 2 uses a binary format for floating point numbers.
    the least-significant 32 bits of *value*; regardless of the size of the
    native :c:expr:`long` type.  *version* indicates the file format.
 
+   This function can fail, in which case it sets the error indicator.
+   Use :c:func:`PyErr_Occurred` to check for that.
 
 .. c:function:: void PyMarshal_WriteObjectToFile(PyObject *value, FILE *file, int version)
 
    Marshal a Python object, *value*, to *file*.
    *version* indicates the file format.
 
+   This function can fail, in which case it sets the error indicator.
+   Use :c:func:`PyErr_Occurred` to check for that.
 
 .. c:function:: PyObject* PyMarshal_WriteObjectToString(PyObject *value, int version)
 
index 41252406060def50e232ee9857afa81f36205a37..67540e08ed99229b706214607414c0f9df706ec2 100644 (file)
@@ -576,6 +576,10 @@ w_clear_refs(WFILE *wf)
 }
 
 /* version currently has no effect for writing ints. */
+/* Note that while the documentation states that this function
+ * can error, currently it never does. Setting an exception in
+ * this function should be regarded as an API-breaking change.
+ */
 void
 PyMarshal_WriteLongToFile(long x, FILE *fp, int version)
 {