]> 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:55:15 +0000 (08:55 +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)

(cherry picked from commit 6a4b8b145620a6532d334e26fd12427e9b9c7b8c)

bin/tests/system/checkds/tests-checkds.py
bin/tests/system/digdelv/yamlget.py

index df8307530ae7d3348891a5f13439aa94d32dcb4d..235bec730fb307ae4ed5c8f819bd11f217b3cde4 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: