Skip to content

gh-159185: Document that PyMarshal_WriteObjectToFile can silently truncate before 3.16 - #159201

Merged
gpshead merged 1 commit into
python:mainfrom
gpshead:marshal-doc-truncated-write
Oct 11, 2026
Merged

gpshead merged 1 commit into
python:mainfrom
gpshead:marshal-doc-truncated-write

Conversation

@gpshead

@gpshead gpshead commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

In Python 3.15 and earlier, PyMarshal_WriteObjectToFile() can return without setting the error indicator after writing only part of the data, for example when the value contains an unmarshallable object or the write fails. That was fixed in 3.16 by gh-155907, which was deliberately not backported. This adds a note so that users of the older versions know to check what was written or use an alternate API. Docs only; intended for backport to 3.15 and 3.14.

…lently before 3.16

In Python 3.15 and earlier, PyMarshal_WriteObjectToFile() ignores most
marshalling errors and all I/O errors: it returns without setting the
error indicator after writing only part of the data.
PyMarshal_WriteLongToFile() ignores I/O errors in the same way.  That
was fixed in 3.16 by pythongh-155907, which is not backported.  Tell the users
of the older versions so that they can check what was written.
@gpshead gpshead self-assigned this Oct 11, 2026
@gpshead gpshead added docs Documentation in the Doc dir needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 11, 2026
@gpshead
gpshead enabled auto-merge (squash) October 11, 2026 21:44
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #35079183 | 📁 Comparing 13e2257 against main (cd71799)

  🔍 Preview build  

1 file changed
± c-api/marshal.html

@gpshead
gpshead merged commit b3714a5 into python:main Oct 11, 2026
41 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @gpshead for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@bedevere-app

bedevere-app Bot commented Oct 11, 2026

Copy link
Copy Markdown

GH-159202 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Oct 11, 2026
@bedevere-app

bedevere-app Bot commented Oct 11, 2026

Copy link
Copy Markdown

GH-159203 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Oct 11, 2026
gpshead added a commit that referenced this pull request Oct 11, 2026
…tly truncate before 3.16 (GH-159201) (#159202)

gh-159185: Document that PyMarshal_WriteObjectToFile can silently truncate before 3.16 (GH-159201)

gh-159185: Document that the PyMarshal file writers can fail silently before 3.16

In Python 3.15 and earlier, PyMarshal_WriteObjectToFile() ignores most
marshalling errors and all I/O errors: it returns without setting the
error indicator after writing only part of the data.
PyMarshal_WriteLongToFile() ignores I/O errors in the same way.  That
was fixed in 3.16 by gh-155907, which is not backported.  Tell the users
of the older versions so that they can check what was written.
(cherry picked from commit b3714a5)

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
gpshead added a commit that referenced this pull request Oct 11, 2026
…tly truncate before 3.16 (GH-159201) (#159203)

gh-159185: Document that PyMarshal_WriteObjectToFile can silently truncate before 3.16 (GH-159201)

gh-159185: Document that the PyMarshal file writers can fail silently before 3.16

In Python 3.15 and earlier, PyMarshal_WriteObjectToFile() ignores most
marshalling errors and all I/O errors: it returns without setting the
error indicator after writing only part of the data.
PyMarshal_WriteLongToFile() ignores I/O errors in the same way.  That
was fixed in 3.16 by gh-155907, which is not backported.  Tell the users
of the older versions so that they can check what was written.
(cherry picked from commit b3714a5)

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant