Commit c3caff5e by Toshio Kuratomi

Fix for six version 1.1.0 (rhel6).

parent 6b642afc
...@@ -36,18 +36,18 @@ from hashlib import sha256 ...@@ -36,18 +36,18 @@ from hashlib import sha256
from hashlib import md5 from hashlib import md5
from binascii import hexlify from binascii import hexlify
from binascii import unhexlify from binascii import unhexlify
from six import binary_type, PY2, text_type from six import binary_type, PY3, text_type
try: try:
from six import byte2int from six import byte2int
except ImportError: except ImportError:
# bytes2int added in six-1.4.0 # bytes2int added in six-1.4.0
if PY2: if PY3:
def byte2int(bs):
return ord(bs[0])
else:
import operator import operator
byte2int = operator.itemgetter(0) byte2int = operator.itemgetter(0)
else:
def byte2int(bs):
return ord(bs[0])
from ansible import constants as C from ansible import constants as C
from ansible.utils.unicode import to_unicode, to_bytes from ansible.utils.unicode import to_unicode, to_bytes
...@@ -463,10 +463,10 @@ class VaultAES(object): ...@@ -463,10 +463,10 @@ class VaultAES(object):
while not finished: while not finished:
chunk, next_chunk = next_chunk, cipher.decrypt(in_file.read(1024 * bs)) chunk, next_chunk = next_chunk, cipher.decrypt(in_file.read(1024 * bs))
if len(next_chunk) == 0: if len(next_chunk) == 0:
if PY2: if PY3:
padding_length = ord(chunk[-1])
else:
padding_length = chunk[-1] padding_length = chunk[-1]
else:
padding_length = ord(chunk[-1])
chunk = chunk[:-padding_length] chunk = chunk[:-padding_length]
finished = True finished = True
...@@ -608,8 +608,8 @@ class VaultAES256(object): ...@@ -608,8 +608,8 @@ class VaultAES256(object):
result = 0 result = 0
for x, y in zip(a, b): for x, y in zip(a, b):
if PY2: if PY3:
result |= ord(x) ^ ord(y)
else:
result |= x ^ y result |= x ^ y
else:
result |= ord(x) ^ ord(y)
return result == 0 return result == 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment