Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d854332

Browse files
committed
a few collection mixins now properly handle private interface implementations
fixes #1785
1 parent 537ddf4 commit d854332

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/runtime/Mixins/collections.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77

88
class IteratorMixin(col.Iterator):
99
def close(self):
10-
self.Dispose()
10+
if hasattr(self, 'Dispose'):
11+
self.Dispose()
12+
else:
13+
from System import IDisposable
14+
IDisposable(self).Dispose()
1115

1216
class IterableMixin(col.Iterable):
1317
pass
@@ -16,7 +20,12 @@ class SizedMixin(col.Sized):
1620
def __len__(self): return self.Count
1721

1822
class ContainerMixin(col.Container):
19-
def __contains__(self, item): return self.Contains(item)
23+
def __contains__(self, item):
24+
if hasattr('self', 'Contains'):
25+
return self.Contains(item)
26+
else:
27+
from System.Collections.Generic import ICollection
28+
return ICollection(self).Contains(item)
2029

2130
try:
2231
abc_Collection = col.Collection

0 commit comments

Comments
 (0)