.NET class instances considered Iterable

Environment

  • Pythonnet version: 2.5.0
  • Python version: 3.7
  • Operating System: Windows

Details

All .NET class instances are considered instances of collections.abc.Iterable.

namespace Python.Test {
  public class Empty { }
}
def test_not_Iterable():
    """Test regular .NET objects are not iterable"""
    from Python.Test import Empty
    from collections.abc import Iterable

    assert (not isinstance(Empty(), Iterable))

The test is expected to pass, but fails:

    def test_not_Iterable():
        """Test regular .NET objects are not iterable"""
        from Python.Test import Empty
        from collections.abc import Iterable

>       assert (not isinstance(Empty(), Iterable))
E       AssertionError: assert not True
E        +  where True = isinstance(<Python.Test.Empty object at 0x0000022D3E6DE5C8>, <class 'collections.abc.Iterable'>)
E        +    where <Python.Test.Empty object at 0x0000022D3E6DE5C8> = <class 'Python.Test.Empty'>()