From 126d8993217e356e771ba9781fb08fa9b3400b11 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 5 Jan 2016 13:19:25 +0100 Subject: [PATCH] Use explicit truncating division In Python 3, the truncating division operator, //, is needed to get C-style "int division". https://fedorahosted.org/freeipa/ticket/5623 Reviewed-By: Jan Cholasta Reviewed-By: Martin Basti --- ipalib/plugins/dns.py | 6 +++--- ipalib/plugins/pwpolicy.py | 4 ++-- ipalib/plugins/trust.py | 2 +- ipaserver/install/ipa_otptoken_import.py | 4 ++-- ipatests/test_integration/util.py | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py index 3da44ef3c..0a9fa1813 100644 --- a/ipalib/plugins/dns.py +++ b/ipalib/plugins/dns.py @@ -361,9 +361,9 @@ def _reverse_zone_name(netstr): net = netaddr.IPNetwork(netstr) items = net.ip.reverse_dns.split('.') if net.version == 4: - return u'.'.join(items[4 - net.prefixlen / 8:]) + return u'.'.join(items[4 - net.prefixlen // 8:]) elif net.version == 6: - return u'.'.join(items[32 - net.prefixlen / 4:]) + return u'.'.join(items[32 - net.prefixlen // 4:]) else: return None @@ -3428,7 +3428,7 @@ class dnsrecord(LDAPObject): resolver = dns.resolver.Resolver() resolver.set_flags(0) # disable recursion (for NS RR checks) max_attempts = int(self.api.env['wait_for_dns']) - warn_attempts = max_attempts / 2 + warn_attempts = max_attempts // 2 period = 1 # second attempt = 0 log_fn = self.log.debug diff --git a/ipalib/plugins/pwpolicy.py b/ipalib/plugins/pwpolicy.py index 4710b48cc..86c559b7d 100644 --- a/ipalib/plugins/pwpolicy.py +++ b/ipalib/plugins/pwpolicy.py @@ -380,11 +380,11 @@ class pwpolicy(LDAPObject): if not options.get('raw', False): if 'krbmaxpwdlife' in entry_attrs: entry_attrs['krbmaxpwdlife'][0] = unicode( - int(entry_attrs['krbmaxpwdlife'][0]) / 86400 + int(entry_attrs['krbmaxpwdlife'][0]) // 86400 ) if 'krbminpwdlife' in entry_attrs: entry_attrs['krbminpwdlife'][0] = unicode( - int(entry_attrs['krbminpwdlife'][0]) / 3600 + int(entry_attrs['krbminpwdlife'][0]) // 3600 ) def convert_time_on_input(self, entry_attrs): diff --git a/ipalib/plugins/trust.py b/ipalib/plugins/trust.py index bc347675a..19d8b53fd 100644 --- a/ipalib/plugins/trust.py +++ b/ipalib/plugins/trust.py @@ -396,7 +396,7 @@ def add_range(myapi, trustinstance, range_name, dom_sid, *keys, **options): max_id = int(max(max_uid, max_gid)[0]) base_id = int(info.get('msSFU30OrderNumber')[0]) - range_size = (1 + (max_id - base_id) / DEFAULT_RANGE_SIZE)\ + range_size = (1 + (max_id - base_id) // DEFAULT_RANGE_SIZE)\ * DEFAULT_RANGE_SIZE # Second, options given via the CLI options take precedence to discovery diff --git a/ipaserver/install/ipa_otptoken_import.py b/ipaserver/install/ipa_otptoken_import.py index 64670a6ff..e68abc889 100644 --- a/ipaserver/install/ipa_otptoken_import.py +++ b/ipaserver/install/ipa_otptoken_import.py @@ -246,9 +246,9 @@ class XMLDecryptor(object): # Decrypt the data. slot = nss.get_best_slot(mech) key = nss.import_sym_key(slot, mech, nss.PK11_OriginUnwrap, nss.CKA_ENCRYPT, self.__key) - iv = nss.param_from_iv(mech, nss.SecItem(data[0:ivlen/8])) + iv = nss.param_from_iv(mech, nss.SecItem(data[0:ivlen//8])) ctx = nss.create_context_by_sym_key(mech, nss.CKA_DECRYPT, key, iv) - out = ctx.cipher_op(data[ivlen / 8:]) + out = ctx.cipher_op(data[ivlen // 8:]) out += ctx.digest_final() return out diff --git a/ipatests/test_integration/util.py b/ipatests/test_integration/util.py index 5cfbb2e94..594737b6d 100644 --- a/ipatests/test_integration/util.py +++ b/ipatests/test_integration/util.py @@ -57,7 +57,7 @@ def run_repeatedly(host, command, assert_zero_rc=True, test=None, raise AssertionError("Command: {cmd} repeatedly failed {times} times, " "exceeding the timeout of {timeout} seconds." .format(cmd=' '.join(command), - times=timeout / time_step, + times=timeout // time_step, timeout=timeout))