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

Commit5f63c67

Browse files
authored
BREAKING: disabled implicit conversion from Python objects implementing sequence protocol to (#1902)
.NET arrays when the target .NET type is `System.Object`. The conversion is still attempted when thetarget type is a `System.Array`fixes#1900
1 parent85d0ca6 commit5f63c67

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

‎CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ or the DLL must be loaded in advance. This must be done before calling any other
6767
- BREAKING: disabled implicit conversion from C# enums to Python`int` and back.
6868
One must now either use enum members (e.g.`MyEnum.Option`), or use enum constructor
6969
(e.g.`MyEnum(42)` or`MyEnum(42, True)` when`MyEnum` does not have a member with value 42).
70+
- BREAKING: disabled implicit conversion from Python objects implementing sequence protocol to
71+
.NET arrays when the target .NET type is`System.Object`. The conversion is still attempted when the
72+
target type is a`System.Array`.
7073
- Sign Runtime DLL with a strong name
7174
- Implement loading through`clr_loader` instead of the included`ClrModule`, enables
7275
support for .NET Core

‎src/runtime/Converter.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,6 @@ internal static bool ToManagedValue(BorrowedReference value, Type obType,
389389
returntrue;
390390
}
391391

392-
if(Runtime.PySequence_Check(value))
393-
{
394-
returnToArray(value,typeof(object[]),outresult,setError);
395-
}
396-
397392
result=newPyObject(value);
398393
returntrue;
399394
}

‎tests/test_conversion.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,13 @@ class Foo(object):
577577
ob.ObjectField=Foo
578578
assertob.ObjectField==Foo
579579

580+
classPseudoSeq:
581+
def__getitem__(self,idx):
582+
return0
583+
584+
ob.ObjectField=PseudoSeq()
585+
assertob.ObjectField.__class__.__name__=="PseudoSeq"
586+
580587

581588
deftest_null_conversion():
582589
"""Test null conversion."""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp