Using String.Format crashes inside pythonnet
See original GitHub issueEnvironment
- Pythonnet version: 3.x
- Python version: 3.8.10
- Operating System: Windows 11 64bit
- .NET Runtime: net6.0
Details
How to reproduce(with project Console.vsproj): @filmor
PythonEngine.Initialize();
PythonEngine.Exec("from System import String\nString.Format('{0},{1}', 1, 2)"); // crashes here
int i = Runtime.Py_Main(cmd.Length, cmd);
PythonEngine.Shutdown();
Issue Analytics
- State:
- Created 2 years ago
- Comments:15 (12 by maintainers)
Top Results From Across the Web
Pythonnet crashes .Net application on exit. · Issue #245
Crash occurs when application exits. This is sample of code that produces crash. Also it contains 'probably workaround".
Read more >pythonnet
I'm trying to define a base class in C# and derive from that class in python / pythonnet. The C# class is very...
Read more >Script crashing when trying to test if a string is an integer
I'm able to convert that to an int with int(), but if there's nothing or if there's something there other than numbers it...
Read more >CHANGELOG.md - pythonnet/pythonnet
Fixed a refcount problem that caused a crash when CLR was imported in an existing installed Python interpreter. Added an automatic conversion from...
Read more >[Python.NET] Embedded Python .Net example - running scripts
The crash I am >> getting happens the second time I run a script that imports ... My environment: >> >> Windows 10...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
System.AccessViolationException: ‘Attempted to read or write protected memory. This is often an indication that other memory is corrupt.’ [External Code]
@sekkit @filmor FYI, the workaround we are planning is going to be somewhat misleading. In your example if you added integer format specifiers, and still used number literals in Python, you would get your format specifiers ignored.
UPD. NVM, I will just add
IFormattable
implementation toPyInt
.