GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [3.15] gh-129724: gh-156504: Make marshal output independent of reference counts (GH-159192) by gpshead · Pull Request #159290 · python/cpython

Conversation

@gpshead

@gpshead gpshead commented Oct 13, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

(cherry picked from commit 48f18f0)

Manual backport notes

A pure cherry-pick conflicted because 3.15 does not have the marshal error handling changes of gh-156942 and gh-155907, nor gh-148653.

  • Python/marshal.c: keeps the WFERR_* error codes of this branch; the new allocation failures use WFERR_NOMEMORY.
  • PyMarshal_WriteLongToFile() and PyMarshal_WriteObjectToFile() still do not report a failure to write to the file, as before on this branch.
  • PyMarshal_WriteObjectToFile() now goes through the same code as marshal.dumps(), so when the object cannot be marshalled it writes nothing and sets ValueError. Before, it wrote partial data and usually returned without an error.
  • Recursive tuples are not detected on this branch (Crash: marshal.loads SIGSEGV on self-referencing TYPE_TUPLE with FLAG_REF #148653), so test_shared_recursion uses a recursive slice.
  • Lib/test/test_capi/test_marshal.py does not exist here: its new cases are in CAPI_TestCase of Lib/test/test_marshal.py, and the _testcapi helper returns the error instead of asserting there is none.
  • Doc/c-api/marshal.rst: the notes about unreported write errors no longer say "In Python 3.15 and earlier"; the versionchanged entry describes the change.
  • Programs/test_frozenmain.h is regenerated.
  • Issue: Bytecode compilation output depends on order of files compiled #129724

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot mentioned this pull request Oct 13, 2026
Bytecode compilation output depends on order of files compiled #129724
Open
@bedevere-app bedevere-app Bot added the type-bug An unexpected behavior, bug, or error label Oct 13, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Oct 13, 2026
gh-129724: gh-156504: Make marshal output independent of reference counts #159192
Merged
@gpshead gpshead self-assigned this Oct 13, 2026
@gpshead gpshead mentioned this pull request Oct 13, 2026
Concurrent compilation changes marshal output in free-threaded builds #156504
Closed
@read-the-docs-community

read-the-docs-community Bot commented Oct 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #35385168 | 📁 Comparing 8fb8fc3 against main (48f18f0)

  🔍 Preview build  

172 files changed · + 2 added · ± 165 modified · - 5 deleted

+ Added

  • c-api/pyexpat.html
  • library/asyncio-policy.html

± Modified

  • index.html
  • license.html
  • py-modindex.html
  • builtins/exceptions.html
  • builtins/functions.html
  • builtins/stdtypes.html
  • c-api/bytes.html
  • c-api/capsule.html
  • c-api/code.html
  • c-api/complex.html
  • and 155 more...

- Deleted

  • deprecations/pending-removal-in-3.21.html
  • library/tkinter.dialogs.html
  • library/tkinter.fontchooser.html
  • library/tkinter.systray.html
  • whatsnew/3.16.html
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@khmyznikov khmyznikov mentioned this pull request Oct 15, 2026
Pip install performance improvements on Windows pypa/pip#14286
Draft
4 tasks done
@gpshead
[3.15] pythongh-129724: pythongh-156504: Make marshal output independ…
8fb8fc3
…ent of reference counts (pythonGH-159192)

The marshal writer decided whether an object can be referenced later
(FLAG_REF) from its reference count, so the output for the same value
depended on what else in the process held a reference to its parts, and
differed between the default and the free-threaded builds' view of the
same objects.  This is the remaining cause of pythongh-129724 and the cause of
pythongh-156504.

FLAG_REF is now set exactly on the objects which are written more than
once in the dump.  The writer still makes one pass: it records the
position of the type byte of each object it remembers and of each
TYPE_REF, and when the dump is complete it sets the flags and renumbers
the references.  A reference count of one is only used to skip the
hashtable.  Interned strings are no longer flagged unconditionally.

The reader is unchanged and the format version is not bumped: both the
old and the new output are loaded by old and new readers.

PyMarshal_WriteObjectToFile() now builds the data in memory and writes
it with one fwrite(), since the flags are only known at the end.
Nothing is written if the object cannot be marshalled.

(cherry picked from commit 48f18f0)
@gpshead
gpshead force-pushed the backport-48f18f0-3.15 branch from 1cd1fc6 to 8fb8fc3 Compare October 24, 2026 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently will be requested when the pull request is marked ready for review ericsnowcurrently is a code owner
@ZeroIntensity ZeroIntensity Awaiting requested review from ZeroIntensity ZeroIntensity will be requested when the pull request is marked ready for review ZeroIntensity is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@gpshead gpshead

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@gpshead
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.