[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [bridgedb/master] Handle case when (ip, portlist) from parseALine() is (None, None).



commit 2fcc3b56bb166c59725b116d466e4bef8701a8c7
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Fri Dec 20 05:23:23 2013 +0000

    Handle case when (ip, portlist) from parseALine() is (None, None).
    
     * FIXES a bug where bridgedb.Bridges.parseStatusFile() doesn't handle the
       (None, None) for (ip, portlist) which is returned whenever
       bridgedb.parse.networkstatus.parseALine() couldn't parse the line.
---
 lib/bridgedb/Bridges.py |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/bridgedb/Bridges.py b/lib/bridgedb/Bridges.py
index e6cf210..177173c 100644
--- a/lib/bridgedb/Bridges.py
+++ b/lib/bridgedb/Bridges.py
@@ -515,11 +515,14 @@ def parseStatusFile(networkstatusFile):
             try:
                 addr, portlist = networkstatus.parseALine(line, toHex(ID))
             except networkstatus.ParseNetstatusError as error:
-                logging.error(error.message)
+                logging.error(error)
             else:
-                try: or_addresses[addr].add(portlist)
-                except KeyError: or_addresses[addr] = portlist
-                parsedORAddressLines += 1
+                if (addr is not None) and (portlist is not None):
+                    try:
+                        or_addresses[addr].add(portlist)
+                    except (KeyError, AttributeError):
+                        or_addresses[addr] = portlist
+                    parsedORAddressLines += 1
 
         elif ID and timestamp and line.startswith("s "):
             running, stable = networkstatus.parseSLine(line)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits