]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Explicitly specify encoding for open() calls
authorMichał Kępień <michal@isc.org>
Thu, 16 Sep 2021 06:22:01 +0000 (08:22 +0200)
committerMichał Kępień <michal@isc.org>
Thu, 16 Sep 2021 06:22:01 +0000 (08:22 +0200)
Address the following warnings reported by PyLint 2.10.2:

    ************* Module tests-checkds
    bin/tests/system/checkds/tests-checkds.py:70:9: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
    bin/tests/system/checkds/tests-checkds.py:120:13: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
    bin/tests/system/checkds/tests-checkds.py:206:17: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
    ************* Module yamlget
    bin/tests/system/digdelv/yamlget.py:22:5: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
    ************* Module stress_http_quota
    bin/tests/system/doth/stress_http_quota.py:131:13: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
    ************* Module tests-rpz-passthru-logging
    bin/tests/system/rpzextra/tests-rpz-passthru-logging.py:40:9: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
    bin/tests/system/rpzextra/tests-rpz-passthru-logging.py:44:9: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)

bin/tests/system/checkds/tests-checkds.py
bin/tests/system/digdelv/yamlget.py
bin/tests/system/doth/stress_http_quota.py
bin/tests/system/rpzextra/tests-rpz-passthru-logging.py

index 1c60c933093c840becc1a8a2810842b5b739b6bc..2561a17024bbf80e6a631db7fa7d4dfb9fcac712 100755 (executable)
@@ -67,7 +67,7 @@ def verify_zone(zone, transfer):
     assert verify is not None
 
     filename = "{}out".format(zone)
-    with open(filename, 'w') as file:
+    with open(filename, 'w', encoding='utf-8') as file:
         for rr in transfer.answer:
             file.write(rr.to_text())
             file.write('\n')
@@ -117,7 +117,7 @@ def read_statefile(server, zone):
     print("read state file {}".format(filename))
 
     try:
-        with open(filename, 'r') as file:
+        with open(filename, 'r', encoding='utf-8') as file:
             for line in file:
                 if line.startswith(';'):
                     continue
@@ -203,7 +203,7 @@ def wait_for_log(filename, log):
         print("read log file {}".format(filename))
 
         try:
-            with open(filename, 'r') as file:
+            with open(filename, 'r', encoding='utf-8') as file:
                 s = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ)
                 if s.find(bytes(log, "ascii")) != -1:
                     found = True
index 60b14cb2d4181e5b0b2b70c85a80759badadf460..9d702036e5326814f093ddccb86aec6f4dea73a4 100644 (file)
@@ -19,7 +19,7 @@ except:
     print("No python yaml module, skipping")
     sys.exit(1)
 
-with open(sys.argv[1], "r") as f:
+with open(sys.argv[1], "r", encoding="utf-8") as f:
     for item in yaml.safe_load_all(f):
         for key in sys.argv[2:]:
             try:
index 1e56538aa98b74d1dd99071d9b6be74cd7bb15e9..e2ddae18198da7dabefd2b508f70077f0ba6b3d1 100755 (executable)
@@ -128,7 +128,7 @@ class SubDIG:
 
     def run(self):
         # pylint: disable=consider-using-with
-        with open(os.devnull, 'w') as devnull:
+        with open(os.devnull, 'w', encoding='utf-8') as devnull:
             self.sub_process = subprocess.Popen(self.get_command(), shell=True,
                                                 stdout=devnull)
 
index c4afa43ae91095c668d6b6118b8f3421eaf84e29..efc0ac053b05d5bcc51bc790945c553db1282b94 100755 (executable)
@@ -37,11 +37,11 @@ def test_rpz_passthru_logging(named_port):
     assert os.path.isfile(rpz_passthru_logfile)
     assert os.path.isfile(rpz_logfile)
 
-    with open(rpz_passthru_logfile) as log_file:
+    with open(rpz_passthru_logfile, encoding='utf-8') as log_file:
         line = log_file.read()
         assert "rpz QNAME PASSTHRU rewrite allowed/A/IN" in line
 
-    with open(rpz_logfile) as log_file:
+    with open(rpz_logfile, encoding='utf-8') as log_file:
         line = log_file.read()
         assert "rpz QNAME PASSTHRU rewrite allowed/A/IN" not in line
         assert "rpz QNAME NXDOMAIN rewrite baddomain/A/IN" in line