[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [sbws/master] relaylist: remove assertions that fail measurement
commit ac9406a6657551b70ae058d4918a31843b0af7a3
Author: juga0 <juga@xxxxxxxxxx>
Date: Sat Dec 15 18:04:46 2018 +0000
relaylist: remove assertions that fail measurement
When the descriptor or network status of a relay was not obtained,
some attributes can't be obtained it can be return None instead
of failing the measurement.
Also, there's no need for hasattr when getattr can just return
None as default.
Closes #28870. Bugfix v0.4.0
---
sbws/lib/relaylist.py | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/sbws/lib/relaylist.py b/sbws/lib/relaylist.py
index 38635ba..b296c06 100644
--- a/sbws/lib/relaylist.py
+++ b/sbws/lib/relaylist.py
@@ -42,14 +42,12 @@ class Relay:
def _from_desc(self, attr):
if not self._desc:
return None
- assert hasattr(self._desc, attr)
- return getattr(self._desc, attr)
+ return getattr(self._desc, attr, None)
def _from_ns(self, attr):
if not self._ns:
return None
- assert hasattr(self._ns, attr)
- return getattr(self._ns, attr)
+ return getattr(self._ns, attr, None)
@property
def nickname(self):
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits