Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a692efe

Browse files
tirkarthiserhiy-storchaka
authored andcommitted
bpo-34166: Fix warnings in Tools/msgfmt.py. (GH-8367)
1 parent 06ca3f0 commit a692efe

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

Tools/i18n/msgfmt.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def generate():
8989
7*4, # start of key index
9090
7*4+len(keys)*8, # start of value index
9191
0, 0) # size and offset of hash table
92-
output += array.array("i", offsets).tostring()
92+
output += array.array("i", offsets).tobytes()
9393
output += ids
9494
output += strs
9595
return output
@@ -109,7 +109,8 @@ def make(filename, outfile):
109109
outfile = os.path.splitext(infile)[0] + '.mo'
110110

111111
try:
112-
lines = open(infile, 'rb').readlines()
112+
with open(infile, 'rb') as f:
113+
lines = f.readlines()
113114
except IOError as msg:
114115
print(msg, file=sys.stderr)
115116
sys.exit(1)
@@ -199,7 +200,8 @@ def make(filename, outfile):
199200
output = generate()
200201

201202
try:
202-
open(outfile,"wb").write(output)
203+
with open(outfile,"wb") as f:
204+
f.write(output)
203205
except IOError as msg:
204206
print(msg, file=sys.stderr)
205207

0 commit comments

Comments
 (0)