Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaa5e504

Browse files
committed
added regression test for#1427
(stack overflow trying to pass `System.Type` to `CanEncode`)
1 parenta2304dc commitaa5e504

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

‎src/embed_tests/Codecs.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,31 @@ public void IterableDecoderTest()
296296
Assert.DoesNotThrow(()=>{codec.TryDecode(pyList,outintEnumerable);});
297297
CollectionAssert.AreEqual(intEnumerable,newList<object>{1,2,3});
298298
}
299+
300+
// regression for https://github.com/pythonnet/pythonnet/issues/1427
301+
[Test]
302+
publicvoidPythonRegisteredDecoder_NoStackOverflowOnSystemType()
303+
{
304+
conststringPyCode=@"
305+
import clr
306+
import System
307+
from Python.Runtime import PyObjectConversions
308+
from Python.Runtime.Codecs import RawProxyEncoder
309+
310+
311+
class ListAsRawEncoder(RawProxyEncoder):
312+
__namespace__ = 'Dummy'
313+
def CanEncode(self, clr_type):
314+
return clr_type.Name == 'IList`1' and clr_type.Namespace == 'System.Collections.Generic'
315+
316+
317+
list_encoder = ListAsRawEncoder()
318+
PyObjectConversions.RegisterEncoder(list_encoder)
319+
320+
system_type = list_encoder.GetType()";
321+
322+
PythonEngine.Exec(PyCode);
323+
}
299324
}
300325

301326
/// <summary>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp