]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-34166: Fix warnings in Tools/msgfmt.py. (GH-8367)
authorXtreak <tirkarthi@users.noreply.github.com>
Sat, 21 Jul 2018 06:22:12 +0000 (11:52 +0530)
committerSerhiy Storchaka <storchaka@gmail.com>
Sat, 21 Jul 2018 06:22:12 +0000 (09:22 +0300)
Tools/i18n/msgfmt.py

index b0751a1ffc1dcdee9c2302d3ce48b5e64376b18b..63d52d1f46e561438b5375dfd87860d6ae27fd15 100755 (executable)
@@ -89,7 +89,7 @@ def generate():
                          7*4,               # start of key index
                          7*4+len(keys)*8,   # start of value index
                          0, 0)              # size and offset of hash table
-    output += array.array("i", offsets).tostring()
+    output += array.array("i", offsets).tobytes()
     output += ids
     output += strs
     return output
@@ -109,7 +109,8 @@ def make(filename, outfile):
         outfile = os.path.splitext(infile)[0] + '.mo'
 
     try:
-        lines = open(infile, 'rb').readlines()
+        with open(infile, 'rb') as f:
+            lines = f.readlines()
     except IOError as msg:
         print(msg, file=sys.stderr)
         sys.exit(1)
@@ -199,7 +200,8 @@ def make(filename, outfile):
     output = generate()
 
     try:
-        open(outfile,"wb").write(output)
+        with open(outfile,"wb") as f:
+            f.write(output)
     except IOError as msg:
         print(msg, file=sys.stderr)