summaryrefslogtreecommitdiff
path: root/addons/payment_adyen/models
diff options
context:
space:
mode:
authorxmo-odoo <xmo@odoo.com>2017-05-10 09:39:55 +0200
committerGitHub <noreply@github.com>2017-05-10 09:39:55 +0200
commitfffaf735f58f1ac57781c095eb552de6d1fcdc47 (patch)
tree88ab0ab65430d871862a836524e0ecc890d1674d /addons/payment_adyen/models
parent10eee18a047d35305dc46282e610e88936d81ffc (diff)
[FIX] P3: list -> iterable builtins (#16811)
In Python 3: * various builtins and dict methods were changed to return view/iterable objects rather than lists * and the separate Python 2 view/iterable builtins and methods were removed altogether This is problematic when using these items as list (which the happens repeatedly in Odoo), but more viciously when iterating *multiple times* over them (which also happens, which I've messed up multiple times while writing this, and which is a pain to debug even when you've just created the issue). Convert all code using these to semantics-matching cross-version helper functions to get the LCD behaviour between P2 and P3, and forbid the builtins via lint. issue #8530
Diffstat (limited to 'addons/payment_adyen/models')
-rw-r--r--addons/payment_adyen/models/payment.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/addons/payment_adyen/models/payment.py b/addons/payment_adyen/models/payment.py
index b54adc58a9c..8b2d8944813 100644
--- a/addons/payment_adyen/models/payment.py
+++ b/addons/payment_adyen/models/payment.py
@@ -8,11 +8,14 @@ import hashlib
import hmac
import logging
import urlparse
+from itertools import chain
from odoo import api, fields, models, tools, _
from odoo.addons.payment.models.payment_acquirer import ValidationError
from odoo.addons.payment_adyen.controllers.main import AdyenController
+from odoo.tools import pycompat
+
_logger = logging.getLogger(__name__)
@@ -46,7 +49,10 @@ class AcquirerAdyen(models.Model):
return val.replace('\\', '\\\\').replace(':', '\\:')
def signParams(parms):
- signing_string = ':'.join(map(escapeVal, parms.keys() + parms.values()))
+ signing_string = ':'.join(
+ escapeVal(v)
+ for v in chain(pycompat.keys(parms), pycompat.values(parms))
+ )
hm = hmac.new(hmac_key, signing_string, hashlib.sha256)
return base64.b64encode(hm.digest())
@@ -74,7 +80,7 @@ class AcquirerAdyen(models.Model):
hmac_key = binascii.a2b_hex(self.adyen_skin_hmac_key.encode('ascii'))
raw_values = {k: values.get(k.encode('ascii'), '') for k in keys if k in values}
- raw_values_ordered = OrderedDict(sorted(raw_values.items(), key=lambda t: t[0]))
+ raw_values_ordered = OrderedDict(sorted(pycompat.items(raw_values), key=lambda t: t[0]))
return signParams(raw_values_ordered)