[PATCH] Explicitly set __hash__ of Base class to None

Łukasz Żarnowiecki dolohow at outlook.com
Fri Aug 5 19:28:53 BST 2016


This suppressing the warning generated when running offlineimap on
python2 with -3 switch:

  offlineimap/folder/Base.py:29: DeprecationWarning: Overriding __eq__
  blocks inheritance of __hash__ in 3.x

Since this object is mutable it should not be hashable.

From Python documentation[1]:

  A class that overrides __eq__() and does not define __hash__() will
  have its __hash__() implicitly set to None.

Therefore old behaviour is preserved.

[1] https://docs.python.org/3/reference/datamodel.html

Signed-off-by: Łukasz Żarnowiecki <dolohow at outlook.com>
---
 offlineimap/folder/Base.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py
index b691c54..0544b3d 100644
--- a/offlineimap/folder/Base.py
+++ b/offlineimap/folder/Base.py
@@ -27,6 +27,8 @@ import offlineimap.accounts
 
 
 class BaseFolder(object):
+    __hash__ = None
+
     def __init__(self, name, repository):
         """
         :param name: Path & name of folder minus root or reference
-- 
2.9.2



More information about the OfflineIMAP-project mailing list