Mercurial > p > roundup > code
changeset 5442:afd9fd3a0edb
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.
| author | Joseph Myers <jsm@polyomino.org.uk> |
|---|---|
| date | Wed, 25 Jul 2018 12:29:08 +0000 |
| parents | a14c0e652e25 |
| children | 447a7647f237 |
| files | roundup/support.py |
| diffstat | 1 files changed, 4 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/roundup/support.py Wed Jul 25 12:28:08 2018 +0000 +++ b/roundup/support.py Wed Jul 25 12:29:08 2018 +0000 @@ -15,11 +15,12 @@ self.keys = {} for col in keys: self.keys[col] = 1 - else: - self.__getitem__ = lambda name: 1 def __getitem__(self, name): - return name in self.keys + if hasattr(self, 'keys'): + return name in self.keys + else: + return True def ensureParentsExist(dest): if not os.path.exists(os.path.dirname(dest)):
