Visitar URL original
Use the BinaryFormatter only on .NET FW and Mono by filmor · Pull Request #2470 · pythonnet/pythonnet · GitHub
Skip to content

Use the BinaryFormatter only on .NET FW and Mono - #2470

Closed
filmor wants to merge 1 commit into
masterfrom
fix-binaryformatter-usage
Closed

filmor wants to merge 1 commit into
masterfrom
fix-binaryformatter-usage

Conversation

@filmor

@filmor filmor commented Oct 1, 2024 •

Copy link
Copy Markdown
Member

Should fix #2469

@filmor
filmor force-pushed the fix-binaryformatter-usage branch from b696f83 to 4ccde5b Compare October 27, 2024 12:46

@lostmsu lostmsu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good, but I'd like NITs to be fixed and the commit squashed

using var buf = new MemoryStream();
var formatter = RuntimeData.CreateFormatter();

if (formatter == null)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be a good idea to make the whole test class [Obsolete] to prevent warnings

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, for the time being, we still by default support this functionality on .NET FW and Mono. Which warning are you referring to?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obsolete code warning that comes from using BinaryFormatter. You can see it on GitHub review page.

Comment thread src/runtime/StateSerialization/RuntimeData.cs Outdated
Comment thread src/runtime/StateSerialization/RuntimeData.cs Outdated
@filmor
filmor force-pushed the fix-binaryformatter-usage branch from 4ccde5b to 1c0afe6 Compare October 28, 2024 07:52
@filmor

filmor commented Oct 28, 2024

Copy link
Copy Markdown
Member Author

Well, without the stashing, Shutdown+Initialize cycles are broken. This is going to be a lot more work than anticipated.

@lostmsu

lostmsu commented Oct 28, 2024 •

Copy link
Copy Markdown
Member

We could consider dropping the support for Shutdown/Initialize for .NET Core+. I don't know if there are any good scenarios for it. It is much safer to spawn a new process.

@filmor
filmor force-pushed the fix-binaryformatter-usage branch from 958dd30 to 3cd685e Compare February 20, 2025 16:29

private static void RestoreRuntimeDataImpl()
{
IFormatter? formatter = CreateFormatter();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think coming here should be an error.

@filmor

filmor commented Oct 25, 2025

Copy link
Copy Markdown
Member Author

/close

@filmor filmor closed this Oct 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BinaryFormatter deprecation issue while using PythonEngine.Shutdown()

2 participants