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.
Comment (by niloct):
I found a fix!
{{{
env.update({'LC_ALL': 'C'})
}}}
This worked!
--
Ticket URL: <https://code.djangoproject.com/ticket/32762#comment:1>
* 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>
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>
* status: closed => new
* resolution: invalid =>
--
Ticket URL: <https://code.djangoproject.com/ticket/32762#comment:4>
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>
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>
* 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>
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>
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>
* owner: nobody => Nilo César Teixeira
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/32762#comment:10>
* 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>
Comment (by Carlton Gibson):
Super, thanks Nilo — Welcome aboard! :) — I'll take a look.
--
Ticket URL: <https://code.djangoproject.com/ticket/32762#comment:12>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/32762#comment:13>
* 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>