Skip to content

Commit 76f4691

Browse files
committed
Python 3 preparation: avoid assigning to instance __getitem__ in TruthDict.
In Python 3, special method names are generally only looked up at the class level, not on instance objects, and so assigning to them for an instance object doesn't work as expected.
1 parent f56f385 commit 76f4691

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

roundup/support.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ def __init__(self, keys):
1515
self.keys = {}
1616
for col in keys:
1717
self.keys[col] = 1
18-
else:
19-
self.__getitem__ = lambda name: 1
2018

2119
def __getitem__(self, name):
22-
return name in self.keys
20+
if hasattr(self, 'keys'):
21+
return name in self.keys
22+
else:
23+
return True
2324

2425
def ensureParentsExist(dest):
2526
if not os.path.exists(os.path.dirname(dest)):

0 commit comments

Comments
 (0)