You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Registering a RawProxyEncoder with PyObjectConversions.RegisterEncoder() causes the script to fail with a stack overflow.
Thanks
First of all, I'd like to say thanks to everyone who's contributed to this project. It's incredibly useful for us to write one set of code to serve both .NET and Python developers. We've had very few problems with Pythonnet. Thanks very much.
Details
I ran into a problem with Pythonnet converting System.Collections.Generic.List into a native python list as described in issue 1153.
lostmsu recommended using a RawProxyEncoder to disable the automatic conversion. Unfortunately, if I register an encoder and then call a .NET method the system crashes with a stack overflow.
I investigated this issue. Stack overflow happens when trying access a C# object, that might need codec (but does not have one), and there's at least one encoder implemented and registered from Python (like ListAsProxyEncoder).
What happens is that in order to call CanEncode Python.NET must pass the clr_type to the encoder. That starts search for encoder, that can handle System.Type, which hits ListAsProxyEncoder.CanEncode again with System.Type, that needs to be passed to Python, and so on.
Activity
lostmsu commentedon Mar 30, 2021
I investigated this issue. Stack overflow happens when trying access a C# object, that might need codec (but does not have one), and there's at least one encoder implemented and registered from Python (like
ListAsProxyEncoder).What happens is that in order to call
CanEncodePython.NET must pass theclr_typeto the encoder. That starts search for encoder, that can handleSystem.Type, which hitsListAsProxyEncoder.CanEncodeagain withSystem.Type, that needs to be passed to Python, and so on.added regression test for pythonnet#1427
added regression test for pythonnet#1427
added regression test for pythonnet#1427
added regression test for pythonnet#1427
disabled ability to register encoders for `System.Type`
added regression test for pythonnet#1427
disabled ability to register encoders for `System.Type`
added regression test for #1427
richard-gemmell-42 commentedon Mar 31, 2021
Thanks for fixing this. I can't believe you did it so quickly.
cheers,
Richard
lostmsu commentedon Mar 31, 2021
Haha, that's for the lack of time to work on new features :-D @richard-gemmell-42
disabled ability to register encoders for `System.Type`