mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
bpo-34166: Fix warnings in Tools/msgfmt.py. (GH-8367)
This commit is contained in:
parent
06ca3f0c09
commit
a692efe473
1 changed files with 5 additions and 3 deletions
|
@ -89,7 +89,7 @@ def generate():
|
||||||
7*4, # start of key index
|
7*4, # start of key index
|
||||||
7*4+len(keys)*8, # start of value index
|
7*4+len(keys)*8, # start of value index
|
||||||
0, 0) # size and offset of hash table
|
0, 0) # size and offset of hash table
|
||||||
output += array.array("i", offsets).tostring()
|
output += array.array("i", offsets).tobytes()
|
||||||
output += ids
|
output += ids
|
||||||
output += strs
|
output += strs
|
||||||
return output
|
return output
|
||||||
|
@ -109,7 +109,8 @@ def make(filename, outfile):
|
||||||
outfile = os.path.splitext(infile)[0] + '.mo'
|
outfile = os.path.splitext(infile)[0] + '.mo'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
lines = open(infile, 'rb').readlines()
|
with open(infile, 'rb') as f:
|
||||||
|
lines = f.readlines()
|
||||||
except IOError as msg:
|
except IOError as msg:
|
||||||
print(msg, file=sys.stderr)
|
print(msg, file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -199,7 +200,8 @@ def make(filename, outfile):
|
||||||
output = generate()
|
output = generate()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
open(outfile,"wb").write(output)
|
with open(outfile,"wb") as f:
|
||||||
|
f.write(output)
|
||||||
except IOError as msg:
|
except IOError as msg:
|
||||||
print(msg, file=sys.stderr)
|
print(msg, file=sys.stderr)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue