Skip to content

.NET class instances considered Iterable #1234

@danabr

Description

@danabr

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'>()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions