Repository navigation
Conversation
…honnet#2282) NoopFormatter serializes nothing. An empty capsule makes the next Initialize call Deserialize and throw. Leave sys.clr_data unset.
A single fix does not need a new credits entry.
Member
|
As it stands, we can't safely re- |
Author
|
You're right, thanks for taking a look. I went back and tested master on net8.0, net9.0 and net10.0. Side question: is there anything left on #2282, or can that one be closed too? It still shows up as open when people search for the BinaryFormatter error. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this implement/fix? Explain your changes.
When
BinaryFormattercannot run,RuntimeData.Stashfalls back toNoopFormatterand still published a zero-lengthsys.clr_datacapsule.NoopFormatter.Serializewrites nothing. The nextPythonEngine.Initializesaw that capsule and calledDeserialize, which throws.Stashnow returns before building or publishing the capsule when the formatter is aNoopFormatter. An existing capsule is cleared so a laterInitializebuilds a fresh runtime instead of restoring an empty one. Runtimes whereBinaryFormatterstill works, including .NET Framework, keep the real stash.Does this close any currently open issues?
#2282
Any other comments?
#2639 already catches the
BinaryFormatterfailure and returnsNoopFormatter, soShutdownitself no longer throwsNotSupportedException. This change stops that fallback from leaving a capsule the nextInitializecannot read.The new embed test calls
Py_Finalizeafter the assertion, thenInitialize. A secondShutdownin the same process deallocates types from the previous runtime and hitsMetaType.tp_deallocin a debug build.GlobalTestsSetupwould do that second shutdown.Local run, with
PYTHONNET_PYDLLset:dotnet test src/embed_tests/Python.EmbeddingTest.csproj -f net10.0242 passed, 5 skipped, 0 failed.
net472was not run here. This machine has nomono.Checklist
AUTHORSCHANGELOG