[Django] #32762: test_msgfmt_error_including_non_ascii fails on Mac OS Catalina, localized msgfmt binary.

46 views
Skip to first unread message

Django

unread,
May 18, 2021, 10:55:04 PM5/18/21
to django-...@googlegroups.com
#32762: test_msgfmt_error_including_non_ascii fails on Mac OS Catalina, localized
msgfmt binary.
------------------------------------------------+------------------------
Reporter: niloct | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: dev
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
{{{
FAIL: test_msgfmt_error_including_non_ascii
(i18n.test_compilation.CompilationErrorHandling)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/Users/teixeira/Downloads/Pessoal/etudes/etudes_py/django_source/tests/i18n/test_compilation.py",
line 204, in test_msgfmt_error_including_non_ascii
self.assertIn("' cannot start a field name", stderr.getvalue())
AssertionError: "' cannot start a field name" not found in 'Execution of
msgfmt failed:
/private/var/folders/sj/kll9fdms3c52l7m19_f_zn980000gn/T/django_al6dgjzh/i18n_cam5a1xi/commands/locale/ko/LC_MESSAGES/django.po:24:
"msgstr" não é um formato de string Python brace válido, ao contrário de
"msgid". Motivo: Na diretiva número 0, "�" não pode iniciar um nome de
campo.\nmsgfmt: encontrado 1 erro fatal\n'
}}}

The `assertIn` fails because the `msgfmt` output is in `pt-BR`. The
`export LANG=C` environment setting on this test doesn't help changing the
binary `msgfmt` output to English.

--
Ticket URL: <https://code.djangoproject.com/ticket/32762>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 18, 2021, 10:59:58 PM5/18/21
to django-...@googlegroups.com
#32762: test_msgfmt_error_including_non_ascii fails on Mac OS Catalina, localized
msgfmt binary.
-------------------------------------+-------------------------------------

Reporter: niloct | Owner: nobody
Type: Bug | Status: new
Component: | Version: dev
Internationalization |
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by niloct):

I found a fix!


{{{
env.update({'LC_ALL': 'C'})
}}}

This worked!

--
Ticket URL: <https://code.djangoproject.com/ticket/32762#comment:1>

Django

unread,
May 19, 2021, 5:12:50 AM5/19/21
to django-...@googlegroups.com
#32762: test_msgfmt_error_including_non_ascii fails on Mac OS Catalina, localized
msgfmt binary.
-------------------------------------+-------------------------------------
Reporter: niloct | Owner: nobody
Type: Bug | Status: closed
Component: | Version: dev
Internationalization |
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* resolution: => invalid


Comment:

Hi.

I'm going to close this as Invalid because I'm pretty sure it's a system
configuration issue.

Happy to help if I can…

In a new shell try the `locale` command. You basically want something
claiming to be `UTF-8`:


{{{
$ locale
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
}}}

You want `pt-br` right? So putting `export LC_ALL=pt_BR.UTF-8` in your
shell startup script may/should solve your issues.

--
Ticket URL: <https://code.djangoproject.com/ticket/32762#comment:2>

Django

unread,
May 19, 2021, 7:39:31 AM5/19/21
to django-...@googlegroups.com
#32762: test_msgfmt_error_including_non_ascii fails on Mac OS Catalina, localized
msgfmt binary.
-------------------------------------+-------------------------------------
Reporter: niloct | Owner: nobody

Type: Bug | Status: closed
Component: | Version: dev
Internationalization |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

Carlton, I'm not sure you got the idea of the ticket. The problem is that
we are checking an English error message content in the Django test
`CompilationErrorHandling.test_msgfmt_error_including_non_ascii`, and we
try to force unlocalize message by `env.update({'LANG': 'C'})` which looks
like is not sufficient in certain systems.

--
Ticket URL: <https://code.djangoproject.com/ticket/32762#comment:3>

Django

unread,
May 19, 2021, 7:57:15 AM5/19/21
to django-...@googlegroups.com
#32762: test_msgfmt_error_including_non_ascii fails on Mac OS Catalina, localized
msgfmt binary.
-------------------------------------+-------------------------------------

Reporter: niloct | Owner: nobody
Type: Bug | Status: new
Component: | Version: dev
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* status: closed => new
* resolution: invalid =>


--
Ticket URL: <https://code.djangoproject.com/ticket/32762#comment:4>

Django

unread,
May 19, 2021, 8:04:43 AM5/19/21
to django-...@googlegroups.com
#32762: test_msgfmt_error_including_non_ascii fails on Mac OS Catalina, localized
msgfmt binary.
-------------------------------------+-------------------------------------

Reporter: niloct | Owner: nobody
Type: Bug | Status: new
Component: | Version: dev
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson):

OK, let's have another look, thanks Claude.

> ...which looks like is not sufficient in certain systems.

Not sure how to proceed.
I can't reproduce without more details on macOS Big Sur.
I'm afraid I don't have Catalina available (but this test never failed for
me over the last few years.)

It still looks like a `locale` issue 🤔 @niloct what output do you get
there?

--
Ticket URL: <https://code.djangoproject.com/ticket/32762#comment:5>

Django

unread,
May 19, 2021, 9:23:39 AM5/19/21
to django-...@googlegroups.com
#32762: test_msgfmt_error_including_non_ascii fails on Mac OS Catalina, localized
msgfmt binary.
-------------------------------------+-------------------------------------

Reporter: niloct | Owner: nobody
Type: Bug | Status: new
Component: | Version: dev
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by niloct):

{{{
~/Downloads/Pessoal/etudes/etudes_py/django_source/tests $ locale
LANG="pt_BR.UTF-8"
LC_COLLATE="pt_BR.UTF-8"
LC_CTYPE="pt_BR.UTF-8"
LC_MESSAGES="pt_BR.UTF-8"
LC_MONETARY="pt_BR.UTF-8"
LC_NUMERIC="pt_BR.UTF-8"
LC_TIME="pt_BR.UTF-8"
LC_ALL="pt_BR.UTF-8"
}}}

For some reason `LANG` isn't enough to reset locale settings, but `LC_ALL`
was.

--
Ticket URL: <https://code.djangoproject.com/ticket/32762#comment:6>

Django

unread,
May 20, 2021, 2:11:42 AM5/20/21
to django-...@googlegroups.com
#32762: test_msgfmt_error_including_non_ascii fails on Mac OS Catalina, localized
msgfmt binary.
--------------------------------------+------------------------------------

Reporter: niloct | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Carlton Gibson):

* stage: Unreviewed => Accepted


Comment:

Super, thanks for the extra info.

{{{
$ LC_ALL="pt_BR.UTF-8" ./runtests.py i18n
}}}

Is sufficient to cause the failure. So the env update will fix it, as you
say.


{{{
diff --git a/tests/i18n/test_compilation.py
b/tests/i18n/test_compilation.py
index 791c1d4f15..915d65e6e1 100644
--- a/tests/i18n/test_compilation.py
+++ b/tests/i18n/test_compilation.py
@@ -193,7 +193,7 @@ class
CompilationErrorHandling(MessageCompilationTests):
# po file contains invalid msgstr content (triggers non-ascii
error content).
# Make sure the output of msgfmt is unaffected by the current
locale.
env = os.environ.copy()
- env.update({'LANG': 'C'})
+ env.update({'LANG': 'C', 'LC_ALL': 'C'})
with mock.patch('django.core.management.utils.run', lambda *args,
**kwargs: run(*args, env=env, **kwargs)):
cmd = MakeMessagesCommand()
if cmd.gettext_version < (0, 18, 3):
}}}


Would you like to make a PR @niloct?

--
Ticket URL: <https://code.djangoproject.com/ticket/32762#comment:7>

Django

unread,
May 20, 2021, 3:29:09 AM5/20/21
to django-...@googlegroups.com
#32762: test_msgfmt_error_including_non_ascii fails on Mac OS Catalina, localized
msgfmt binary.
--------------------------------------+------------------------------------

Reporter: niloct | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Carlton Gibson):

Checking the [https://man7.org/linux/man-pages/man7/locale.7.html locale
man page], `LC_ALL` if present trumps all else, so the `LANG` setting can
be replaced in the test, rather than added to, I think.

--
Ticket URL: <https://code.djangoproject.com/ticket/32762#comment:8>

Django

unread,
May 20, 2021, 9:59:34 AM5/20/21
to django-...@googlegroups.com
#32762: test_msgfmt_error_including_non_ascii fails on Mac OS Catalina, localized
msgfmt binary.
--------------------------------------+------------------------------------
Reporter: Nilo César Teixeira | Owner: nobody

Type: Bug | Status: new
Component: Internationalization | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Nilo César Teixeira):

Replying to [comment:8 Carlton Gibson]:


> Checking the [https://man7.org/linux/man-pages/man7/locale.7.html locale
man page], `LC_ALL` if present trumps all else, so the `LANG` setting can
be replaced in the test, rather than added to, I think.

Hi Carlton!

Yes I saw that man. Awesome that you concur :)

Sorry for the delay in response, I wasn't notified because I hadn't
updated my profile with my e-mail, despite the big yellow box shouting
this to me!

Regarding the pull request, I'm just starting reading through the docs
(finished the `toast` contribution), would I have to change any docs in
the pr or just the test with a comment about it ?

Thanks!

--
Ticket URL: <https://code.djangoproject.com/ticket/32762#comment:9>

Django

unread,
May 20, 2021, 2:43:12 PM5/20/21
to django-...@googlegroups.com
#32762: test_msgfmt_error_including_non_ascii fails on Mac OS Catalina, localized
msgfmt binary.
-------------------------------------+-------------------------------------
Reporter: Nilo César Teixeira | Owner: Nilo
| César Teixeira
Type: Bug | Status: assigned
Component: | Version: dev
Internationalization |

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Nilo César Teixeira):

* owner: nobody => Nilo César Teixeira
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/32762#comment:10>

Django

unread,
May 20, 2021, 2:48:16 PM5/20/21
to django-...@googlegroups.com
#32762: test_msgfmt_error_including_non_ascii fails on Mac OS Catalina, localized
msgfmt binary.
-------------------------------------+-------------------------------------
Reporter: Nilo César Teixeira | Owner: Nilo
| César Teixeira
Type: Bug | Status: assigned
Component: | Version: dev
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Nilo César Teixeira):

* has_patch: 0 => 1


Comment:

Well, I did it I guess.

Please take a look. It's my first contribution to Django :)

[https://github.com/django/django/pull/14426]

--
Ticket URL: <https://code.djangoproject.com/ticket/32762#comment:11>

Django

unread,
May 25, 2021, 2:56:28 AM5/25/21
to django-...@googlegroups.com
#32762: test_msgfmt_error_including_non_ascii fails on Mac OS Catalina, localized
msgfmt binary.
-------------------------------------+-------------------------------------
Reporter: Nilo César Teixeira | Owner: Nilo
| César Teixeira
Type: Bug | Status: assigned
Component: | Version: dev
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson):

Super, thanks Nilo — Welcome aboard! :) — I'll take a look.

--
Ticket URL: <https://code.djangoproject.com/ticket/32762#comment:12>

Django

unread,
May 26, 2021, 9:49:56 AM5/26/21
to django-...@googlegroups.com
#32762: test_msgfmt_error_including_non_ascii fails on Mac OS Catalina, localized
msgfmt binary.
-------------------------------------+-------------------------------------
Reporter: Nilo César Teixeira | Owner: Nilo
| César Teixeira
Type: Bug | Status: assigned
Component: | Version: dev
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/32762#comment:13>

Django

unread,
May 26, 2021, 10:14:24 AM5/26/21
to django-...@googlegroups.com
#32762: test_msgfmt_error_including_non_ascii fails on Mac OS Catalina, localized
msgfmt binary.
-------------------------------------+-------------------------------------
Reporter: Nilo César Teixeira | Owner: Nilo
| César Teixeira
Type: Bug | Status: closed
Component: | Version: dev
Internationalization |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson <carlton.gibson@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"0d67481a6664a1e66d875eef59b96ed489060601" 0d67481]:
{{{
#!CommitTicketReference repository=""
revision="0d67481a6664a1e66d875eef59b96ed489060601"
Fixed #32762 -- Fixed locale reset in compilemessages test.

Reset the `LC_ALL` override value in the test environment to ensure that
locale
values the calling environment are not used.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32762#comment:14>

Reply all
Reply to author
Forward
0 new messages