Linux wireless drivers development
 help / color / mirror / Atom feed
From: Seth Forshee <seth.forshee@canonical.com>
To: wireless-regdb@lists.infradead.org
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH] wireless-regdb: Fix comparison of WmmRule with NoneType in python 3
Date: Fri, 18 May 2018 09:47:01 -0500	[thread overview]
Message-ID: <20180518144701.25138-1-seth.forshee@canonical.com> (raw)

Python 3 gives errors as a result of the changes to add wmm
rules since Permission.wmmrule can be set to None:

 TypeError: '<' not supported between instances of 'WmmRule' and 'NoneType'

To fix this, supply compairson methods for WmmRule instead of
using the ones provided by attrs. Doing this means we also need
to supply a __hash__ method.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
 dbparse.py | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/dbparse.py b/dbparse.py
index 5cb8b3f13266..5fe752b4ff31 100755
--- a/dbparse.py
+++ b/dbparse.py
@@ -32,7 +32,7 @@ dfs_regions = {
 
 @total_ordering
 
-@attr.s(frozen=True)
+@attr.s(frozen=True, cmp=False)
 class WmmRule(object):
     vo_c = attr.ib()
     vi_c = attr.ib()
@@ -47,6 +47,22 @@ class WmmRule(object):
         return (self.vo_c, self.vi_c, self.be_c, self.bk_c,
                 self.vo_ap, self.vi_ap, self.be_ap, self.bk_ap)
 
+    def __eq__(self, other):
+        if other is None:
+            return False
+        return (self._as_tuple() == other._as_tuple())
+
+    def __ne__(self, other):
+        return not (self == other)
+
+    def __lt__(self, other):
+        if other is None:
+            return False
+        return (self._as_tuple() < other._as_tuple())
+
+    def __hash__(self):
+        return hash(self._as_tuple())
+
 class FreqBand(object):
     def __init__(self, start, end, bw, comments=None):
         self.start = start
-- 
2.17.0

             reply	other threads:[~2018-05-18 14:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-18 14:47 Seth Forshee [this message]
2018-05-25 16:34 ` [PATCH] wireless-regdb: Fix comparison of WmmRule with NoneType in python 3 Seth Forshee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180518144701.25138-1-seth.forshee@canonical.com \
    --to=seth.forshee@canonical.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=wireless-regdb@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox