PY3: wrap filter calls with list where list is expected
authorNoel Power <noel.power@suse.com>
Wed, 28 Nov 2018 14:15:23 +0000 (14:15 +0000)
committerNoel Power <npower@samba.org>
Mon, 10 Dec 2018 09:38:21 +0000 (10:38 +0100)
filter in PY2 returns list in PY3 it returns an iterator

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/auth_log.py
python/samba/tests/auth_log_base.py
selftest/tests.py
source4/selftest/tests.py

index 961401aa2e88ca8f39d50ac53b44358b26220878..2b280bcc3c13bc79a6512434401c54c333f89c21 100644 (file)
@@ -70,7 +70,7 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
         # Turn "[foo,bar]" into a list ("foo", "bar") to test
         # lambda x: x removes anything that evaluates to False,
         # including empty strings, so we handle "" as well
-        binding_list = filter(lambda x: x, re.compile('[\[,\]]').split(binding))
+        binding_list = list(filter(lambda x: x, re.compile('[\[,\]]').split(binding)))
 
         # Handle explicit smb2, smb1 or auto negotiation
         if "smb2" in binding_list:
index 6edd0f6e953523dcc216c79b5e7fcd28ed36b8fe..700871f9df5b65cea427bffb6502cc9f7098794a 100644 (file)
@@ -97,7 +97,7 @@ class AuthLogTestBase(samba.tests.TestCase):
                 return []
 
         self.connection = None
-        return filter(isRemote, self.context["messages"])
+        return list(filter(isRemote, self.context["messages"]))
 
     # Discard any previously queued messages.
     def discardMessages(self):
index 1658dd2b854347fe4d8a9ab4dbe728226eb1fb79..3de981f7e1324656c000411195cbd71025ca0d68 100644 (file)
@@ -38,7 +38,7 @@ try:
     lines = f.readlines()
     config_hash = dict((x[0], ' '.join(x[1:]))
                        for x in map(lambda line: line.strip().split(' ')[1:],
-                                    filter(lambda line: (line[0:7] == '#define') and (len(line.split(' ')) > 2), lines)))
+                                    list(filter(lambda line: (line[0:7] == '#define') and (len(line.split(' ')) > 2), lines))))
 finally:
     f.close()
 
index c676b878b838a0cc3e31d94401878e0ce068e732..ca43770dfca9bd38ee7de6625a7196281ee72b7a 100755 (executable)
@@ -76,7 +76,7 @@ try:
     lines = f.readlines()
     config_hash = dict((x[0], ' '.join(x[1:]))
                        for x in map(lambda line: line.strip().split(' ')[1:],
-                                    filter(lambda line: (line[0:7] == '#define') and (len(line.split(' ')) > 2), lines)))
+                                    list(filter(lambda line: (line[0:7] == '#define') and (len(line.split(' ')) > 2), lines))))
 finally:
     f.close()
 
@@ -177,7 +177,7 @@ all_rpc_tests = ncalrpc_tests + ncacn_np_tests + ncacn_ip_tcp_tests + slow_ncacn
 
 # Make sure all tests get run
 rpc_tests = smbtorture4_testsuites("rpc.")
-auto_rpc_tests = filter(lambda t: t not in all_rpc_tests, rpc_tests)
+auto_rpc_tests = list(filter(lambda t: t not in all_rpc_tests, rpc_tests))
 
 for bindoptions in ["seal,padcheck"] + validate_list + ["bigendian"]:
     for transport in ["ncalrpc", "ncacn_np", "ncacn_ip_tcp"]:
@@ -230,7 +230,7 @@ for t in smbtorture4_testsuites("dfs."):
     plansmbtorture4testsuite(t, "ad_dc", '//$SERVER/ipc\$ -U$USERNAME%$PASSWORD')
 
 # Tests for the NET API (net.api.become.dc tested below against all the roles)
-net_tests = filter(lambda x: "net.api.become.dc" not in x, smbtorture4_testsuites("net."))
+net_tests = list(filter(lambda x: "net.api.become.dc" not in x, smbtorture4_testsuites("net.")))
 for t in net_tests:
     plansmbtorture4testsuite(t, "ad_dc_ntvfs", '$SERVER[%s] -U$USERNAME%%$PASSWORD -W$DOMAIN' % validate)