diff --git a/liberapay/billing/payday.py b/liberapay/billing/payday.py index 65f7e8527..6e185bea3 100644 --- a/liberapay/billing/payday.py +++ b/liberapay/billing/payday.py @@ -539,7 +539,7 @@ def resolve_takes(tips, takes, ref_currency, payday_id): # members who have now left the team or have zeroed takes. transfers = list(transfers.values()) leftover = total_income - MoneyBasket(t.amount for t in transfers) - assert leftover >= 0 + assert leftover >= 0, "leftover is negative" if leftover and leftover_takes: leftover_takes.sort(key=lambda t: t.member) leftover_takes_fuzzy_sum = MoneyBasket( diff --git a/liberapay/i18n/currencies.py b/liberapay/i18n/currencies.py index 3bb355a46..a840f0a67 100644 --- a/liberapay/i18n/currencies.py +++ b/liberapay/i18n/currencies.py @@ -393,9 +393,9 @@ def __ne__(self, other): def _compare(self, op, other): if isinstance(other, self.__class__): - return self.amounts == other.amounts + return self.amounts.items() == other.amounts.items() elif other == 0: - return any(op(v, 0) for v in self.amounts.values()) + return all(op(v, 0) for v in self.amounts.values()) else: raise TypeError( "can't compare %r and %r" % (self.__class__, other.__class__) diff --git a/liberapay/utils/state_chain.py b/liberapay/utils/state_chain.py index f7dc4b2e9..ca21d5c6e 100644 --- a/liberapay/utils/state_chain.py +++ b/liberapay/utils/state_chain.py @@ -1,7 +1,6 @@ -from urllib.parse import quote as urlquote, urlsplit, urlunsplit +from urllib.parse import quote as urlquote from pando import Response -from pando.http.request import Line import pando.state_chain from requests.exceptions import ConnectionError, Timeout @@ -54,14 +53,6 @@ def canonize(request, response, website): """ if request.path.raw.startswith('/callbacks/'): # Don't redirect callbacks - if request.path.raw[-1] == '/': - # Remove trailing slash - l = request.line - scheme, netloc, path, query, fragment = urlsplit(l.uri) - assert path[-1] == '/' # sanity check - path = path[:-1] - new_uri = urlunsplit((scheme, netloc, path, query, fragment)) - request.line = Line(l.method.raw, new_uri, l.version.raw) return canonical_host = website.canonical_host canonical_scheme = website.canonical_scheme