FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Disabled implicit seq to array conversion by lostmsu · Pull Request #1902 · pythonnet/pythonnet · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cs  (1) .md  (1) .py  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
3 changes: 3 additions & 0 deletions CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL