diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-06-04 21:08:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-05 00:08:36 -0400 |
commit | 32590d5fbd29c258316793ac0992ed8d45bfb1e8 (patch) | |
tree | 2b8be8779dc125b6f0e449c2203de9188962b708 | |
parent | [3.7] gh-102153: Start stripping C0 control and space chars in `urlsplit` (GH... (diff) | |
download | cpython-32590d5fbd29c258316793ac0992ed8d45bfb1e8.tar.gz cpython-32590d5fbd29c258316793ac0992ed8d45bfb1e8.tar.bz2 cpython-32590d5fbd29c258316793ac0992ed8d45bfb1e8.zip |
[3.7] gh-105184: document that marshal functions can fail and need to be checked with PyErr_Occurred (GH-105223)
(cherry picked from commit ee26ca13a129da8cf549409d0a1b2e892ff2b4ec)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
-rw-r--r-- | Doc/c-api/marshal.rst | 4 | ||||
-rw-r--r-- | Python/marshal.c | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/Doc/c-api/marshal.rst b/Doc/c-api/marshal.rst index bf5fb4ecbb7..8c444223b9d 100644 --- a/Doc/c-api/marshal.rst +++ b/Doc/c-api/marshal.rst @@ -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:type:`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) diff --git a/Python/marshal.c b/Python/marshal.c index 2e911b7be27..a4ca71388e6 100644 --- a/Python/marshal.c +++ b/Python/marshal.c @@ -619,6 +619,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) { |