From 87f96a65e44957f67c9145a0965cfa4fb3bcd61e Mon Sep 17 00:00:00 2001 From: ttanay Date: Sun, 3 Mar 2019 20:15:03 +0530 Subject: [PATCH 1/3] Add __hash__ to class Message to make it hashable in Python 3 The class Message defines a __eq__ method, but, does not define a __hash__ method. This makes it unhashable in Python 3. But, it is hashable in Python 2. --- apitools/base/protorpclite/messages.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apitools/base/protorpclite/messages.py b/apitools/base/protorpclite/messages.py index 0d564e91..1382fc66 100644 --- a/apitools/base/protorpclite/messages.py +++ b/apitools/base/protorpclite/messages.py @@ -758,6 +758,8 @@ class Order(Message): """ + __hash__ = object.__hash__ + def __init__(self, **kwargs): """Initialize internal messages state. From 0ace8214625d50efa54022fcf56d47afdc50f2e3 Mon Sep 17 00:00:00 2001 From: ttanay Date: Mon, 11 Mar 2019 22:39:06 +0530 Subject: [PATCH 2/3] Make __hash__ implementation consistent with __eq__ --- apitools/base/protorpclite/messages.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apitools/base/protorpclite/messages.py b/apitools/base/protorpclite/messages.py index 1382fc66..38e90ec8 100644 --- a/apitools/base/protorpclite/messages.py +++ b/apitools/base/protorpclite/messages.py @@ -758,8 +758,6 @@ class Order(Message): """ - __hash__ = object.__hash__ - def __init__(self, **kwargs): """Initialize internal messages state. @@ -1060,6 +1058,10 @@ def __ne__(self, other): """ return not self.__eq__(other) + def __hash__(self): + """Hash by __tags""" + return hash(self.__tags) + class FieldList(list): """List implementation that validates field values. From ea930a33ea0141c110d755b934b9a253fbb249b8 Mon Sep 17 00:00:00 2001 From: ttanay Date: Tue, 12 Mar 2019 02:26:30 +0530 Subject: [PATCH 3/3] Make __hash__ None for class Message --- apitools/base/protorpclite/messages.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apitools/base/protorpclite/messages.py b/apitools/base/protorpclite/messages.py index 38e90ec8..6a1fef2f 100644 --- a/apitools/base/protorpclite/messages.py +++ b/apitools/base/protorpclite/messages.py @@ -758,6 +758,8 @@ class Order(Message): """ + __hash__ = None + def __init__(self, **kwargs): """Initialize internal messages state. @@ -1058,10 +1060,6 @@ def __ne__(self, other): """ return not self.__eq__(other) - def __hash__(self): - """Hash by __tags""" - return hash(self.__tags) - class FieldList(list): """List implementation that validates field values.