Skip to content

Disabled implicit seq to array conversion #1902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ or the DLL must be loaded in advance. This must be done before calling any other
- BREAKING: disabled implicit conversion from C# enums to Python `int` and back.
One must now either use enum members (e.g. `MyEnum.Option`), or use enum constructor
(e.g. `MyEnum(42)` or `MyEnum(42, True)` when `MyEnum` does not have a member with value 42).
- BREAKING: disabled implicit conversion from Python objects implementing sequence protocol to
.NET arrays when the target .NET type is `System.Object`. The conversion is still attempted when the
target type is a `System.Array`.
- Sign Runtime DLL with a strong name
- Implement loading through `clr_loader` instead of the included `ClrModule`, enables
support for .NET Core
Expand Down
5 changes: 0 additions & 5 deletions src/runtime/Converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,6 @@ internal static bool ToManagedValue(BorrowedReference value, Type obType,
return true;
}

if (Runtime.PySequence_Check(value))
{
return ToArray(value, typeof(object[]), out result, setError);
}

result = new PyObject(value);
return true;
}
Expand Down
7 changes: 7 additions & 0 deletions tests/test_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,13 @@ class Foo(object):
ob.ObjectField = Foo
assert ob.ObjectField == Foo

class PseudoSeq:
def __getitem__(self, idx):
return 0

ob.ObjectField = PseudoSeq()
assert ob.ObjectField.__class__.__name__ == "PseudoSeq"


def test_null_conversion():
"""Test null conversion."""
Expand Down