diff options
| author | Philipp Winter <phw@nymity.ch> | 2020-05-22 15:52:45 -0700 |
|---|---|---|
| committer | Philipp Winter <phw@nymity.ch> | 2020-05-22 15:52:45 -0700 |
| commit | 5c0b04ed012cb81574d459f847db534086ce62d0 (patch) | |
| tree | 1963d3b68835db1319924c69803ce786974fe882 | |
| parent | 19ba2da7b66cfccee014bde2804f10dafd0696b7 (diff) | |
| parent | 2abd54a1b979c11153c41a51b884386fbd4635c4 (diff) | |
Merge branch 'defect/33945' into develop
| -rw-r--r-- | CHANGELOG | 4 | ||||
| -rw-r--r-- | bridgedb/Storage.py | 63 |
2 files changed, 5 insertions, 62 deletions
@@ -1,3 +1,7 @@ + * FIXES https://bugs.torproject.org/33945 + This patch fixes a bug that caused the email autoresponder to fail after + a while. + * FIXES https://bugs.torproject.org/34154 Add new fields to the SQLite table BlockedBridges in preparation for taking into account OONI's bridge measurement results. diff --git a/bridgedb/Storage.py b/bridgedb/Storage.py index 0fe8851..2859cf1 100644 --- a/bridgedb/Storage.py +++ b/bridgedb/Storage.py @@ -10,6 +10,7 @@ import time import hashlib from functools import wraps from ipaddr import IPAddress +from contextlib import contextmanager import sys from bridgedb.Stability import BridgeHistory @@ -345,68 +346,6 @@ def openDatabase(sqlite_file): return conn -class DBGeneratorContextManager(object): - """Helper for @contextmanager decorator. - - Overload __exit__() so we can call the generator many times - """ - - def __init__(self, gen): - self.gen = gen - - def __enter__(self): - return next(self.gen) - - def __exit__(self, type, value, traceback): - """Handle exiting a with statement block - - Progress generator or throw exception - - Significantly based on contextlib.py - - :throws: `RuntimeError` if the generator doesn't stop after - exception is thrown - """ - if type is None: - try: - next(self.gen) - except StopIteration: - return - return - else: - if value is None: - # Need to force instantiation so we can reliably - # tell if we get the same exception back - value = type() - try: - self.gen.throw(type, value, traceback) - raise RuntimeError("generator didn't stop after throw()") - except StopIteration as exc: - # Suppress the exception *unless* it's the same exception that - # was passed to throw(). This prevents a StopIteration - # raised inside the "with" statement from being suppressed - return exc is not value - except: - # only re-raise if it's *not* the exception that was - # passed to throw(), because __exit__() must not raise - # an exception unless __exit__() itself failed. But throw() - # has to raise the exception to signal propagation, so this - # fixes the impedance mismatch between the throw() protocol - # and the __exit__() protocol. - # - if sys.exc_info()[1] is not value: - raise - -def contextmanager(func): - """Decorator to for :func:`Storage.getDB()` - - Define getDB() for use by with statement content manager - """ - @wraps(func) - def helper(*args, **kwds): - return DBGeneratorContextManager(func(*args, **kwds)) - return helper - _DB_FNAME = None _LOCK = None _LOCKED = 0 |
