[tor-commits] [bridgedb/master] Change an assert to a check+log in bridgedb.Main.

isis at torproject.org isis at torproject.org
Sun Jan 12 06:06:31 UTC 2014


commit 21f88bde6fa4f13ebdd16178feb22b6745cb4d9c
Author: Isis Lovecruft <isis at torproject.org>
Date:   Tue Nov 5 06:11:27 2013 +0000

    Change an assert to a check+log in bridgedb.Main.
    
    This is done so that if BridgeDB is run with higher-than-default optimization
    levels, i.e. ``python -O2`` (which strips out assert statements), then the
    problem will still get logged.
    
     * CHANGE an assert statement which checks that a
       ``Bridges.PluggableTransport`` added to a ``Bridges.Bridge.transports``
       list actually got added, into a more explicit, non-assert check with a log
       statement if it fails.
---
 lib/bridgedb/Main.py |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/bridgedb/Main.py b/lib/bridgedb/Main.py
index b949b00..cc53ecf 100644
--- a/lib/bridgedb/Main.py
+++ b/lib/bridgedb/Main.py
@@ -142,8 +142,9 @@ def load(cfg, splitter, clear=False):
                     bridgePT = Bridges.PluggableTransport(
                         bridges[ID], method_name, address, port, argdict)
                     bridges[ID].transports.append(bridgePT)
-                    assert bridges[ID].transports, \
-                        "We added a transport but it disappeared!"
+                    if not bridgePT in bridges[ID].transports:
+                        logging.critical("""Added transport...it disappeared!
+                        Transport: %r""" % bridgePT)
             except KeyError as error:
                 logging.error("Could not find bridge with fingerprint '%s'."
                               % Bridges.toHex(ID))





More information about the tor-commits mailing list