py3: ipa_otptoken_import: fix lamba code inspection

lambda in py3 has '__code__' attribute instead of 'func_code'

https://pagure.io/freeipa/issue/4985

Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
This commit is contained in:
Martin Basti 2017-06-20 10:00:59 +02:00
parent 8416d5772d
commit 24eadd3a39

View File

@ -378,7 +378,10 @@ class PSKCKeyPackage(object):
result = fetch(element, path)
if result is not None:
if getattr(getattr(v[1], "func_code", None), "co_argcount", 0) > 1:
lambda_code_attr = "__code__" if six.PY3 else "func_code"
if getattr(
getattr(v[1], lambda_code_attr, None),
"co_argcount", 0) > 1:
data[v[0]] = v[1](result, decryptor)
else:
data[v[0]] = v[1](result)