classification
Title: Tools/msgfmt.py emits a DeprecationWarning under Python 3.7
Type: Stage: resolved
Components: Demos and Tools Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: lelit, miss-islington, serhiy.storchaka, xtreak
Priority: normal Keywords: patch

Created on 2018-07-20 12:06 by lelit, last changed 2018-07-22 10:47 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
django.po xtreak, 2018-07-21 05:34
Pull Requests
URL Status Linked Edit
PR 8367 merged xtreak, 2018-07-21 05:46
PR 8368 merged miss-islington, 2018-07-21 06:22
PR 8369 merged xtreak, 2018-07-21 06:24
Messages (5)
msg322001 - (view) Author: Lele Gaifax (lelit) * Date: 2018-07-20 12:06
$ python3.7 msgfmt.py -o test.mo test.po 
msgfmt.py:199: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  output = generate()
msg322074 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-07-21 05:34
I could see some unclosed file handlers as well. The last commit (c56894d305211c98882898f237ff54f620520139) was also made in 2013 and I could see no tests for tools too.

➜  cpython git:(master) ✗ ./python ./Tools/i18n/msgfmt.py -o django-no-patch.mo django.po
./Tools/i18n/msgfmt.py:112: ResourceWarning: unclosed file <_io.BufferedReader name='django.po'>
  lines = open(infile, 'rb').readlines()
./Tools/i18n/msgfmt.py:199: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
  output = generate()
./Tools/i18n/msgfmt.py:202: ResourceWarning: unclosed file <_io.BufferedWriter name='django-no-patch.mo'>
  open(outfile,"wb").write(output)
➜  cpython git:(bpo34166) ✗ ./python -Werror ./Tools/i18n/msgfmt.py -o django-patch.mo django.po

➜  cpython git:(bpo34166) ✗ sha1sum django-patch.mo
ab77140e8638adfdef6d00d6c02cc926f1dc906f  django-patch.mo
➜  cpython git:(bpo34166) ✗ sha1sum django-no-patch.mo
ab77140e8638adfdef6d00d6c02cc926f1dc906f  django-no-patch.mo

I will raise a PR. Attaching a sample .po file from django project used in the above command for testing.

Thanks
msg322077 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-07-21 06:22
New changeset a692efe4733f98831cb51a9683877b152f754d14 by Serhiy Storchaka (Xtreak) in branch 'master':
bpo-34166: Fix warnings in Tools/msgfmt.py. (GH-8367)
https://github.com/python/cpython/commit/a692efe4733f98831cb51a9683877b152f754d14
msg322079 - (view) Author: miss-islington (miss-islington) Date: 2018-07-21 07:24
New changeset 916bcc6fde2db95199454b22f608648467fbbc54 by Miss Islington (bot) in branch '3.6':
bpo-34166: Fix warnings in Tools/msgfmt.py. (GH-8367)
https://github.com/python/cpython/commit/916bcc6fde2db95199454b22f608648467fbbc54
msg322080 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-07-21 07:25
New changeset 25326dea8b907fdd2bf087baab3c31b617438f2e by Serhiy Storchaka (Xtreak) in branch '3.7':
[3.7] bpo-34166: Fix warnings in Tools/msgfmt.py. (GH-8367) (GH-8369)
https://github.com/python/cpython/commit/25326dea8b907fdd2bf087baab3c31b617438f2e
History
Date User Action Args
2018-07-22 10:47:07serhiy.storchakasetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: + Python 3.6, Python 3.8
2018-07-21 07:25:06serhiy.storchakasetmessages: + msg322080
2018-07-21 07:24:44miss-islingtonsetnosy: + miss-islington
messages: + msg322079
2018-07-21 06:24:50xtreaksetpull_requests: + pull_request7903
2018-07-21 06:22:27miss-islingtonsetpull_requests: + pull_request7902
2018-07-21 06:22:14serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg322077
2018-07-21 05:46:03xtreaksetkeywords: + patch
stage: patch review
pull_requests: + pull_request7901
2018-07-21 05:34:57xtreaksetfiles: + django.po
nosy: + xtreak
messages: + msg322074

2018-07-20 12:06:04lelitcreate