#29452: makemessages command doesn't set .pot file charset properly
-------------------------------------+-------------------------------------
     Reporter:  Bartosz Grabski      |                    Owner:  Bartosz
                                     |  Grabski
         Type:  Bug                  |                   Status:  assigned
    Component:                       |                  Version:  1.11
  Internationalization               |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Ramiro Morales):

 I'm the one who introduced this bug in
 6ab0d1358fc78077064aab88a4fb0a47ca116391. ''Mea culpa''.

 I can contribute a test case (also attached):
 {{{
 #!diff
 diff --git a/tests/i18n/commands/templates/test.html
 b/tests/i18n/commands/templates/test.html
 index cac034e..3868dc1 100644
 --- a/tests/i18n/commands/templates/test.html
 +++ b/tests/i18n/commands/templates/test.html
 @@ -105,3 +105,5 @@ Plural for a `trans` and `blocktrans` collision case
  {% endblocktrans %}

  {% trans "Non-breaking space :" %}
 +
 +{% trans "Nón-ÁSCÍÏ text" %}
 diff --git a/tests/i18n/test_extraction.py b/tests/i18n/test_extraction.py
 index d9ce3b4..e7557fc 100644
 --- a/tests/i18n/test_extraction.py
 +++ b/tests/i18n/test_extraction.py
 @@ -394,6 +394,14 @@ class BasicExtractorTests(ExtractorTests):
              po_contents = fp.read()
              self.assertMsgStr("Größe", po_contents)

 +    def test_pot_charset_header_is_utf8(self):
 +        self.assertFalse(os.path.exists(self.POT_FILE))
 +        management.call_command('makemessages', locale=[LOCALE],
 verbosity=0, keep_pot=True)
 +        self.assertTrue(os.path.exists(self.POT_FILE))
 +        with open(self.POT_FILE, 'r', encoding='utf-8') as fp:
 +            contents = fp.read()
 +            self.assertIn(r'; charset=UTF-8\n"', contents)
 +

  class JavascriptExtractorTests(ExtractorTests):

 }}}

 Problem is I can't reproduce the error condition.

 In the added test case:
 * There is a translatable literal with non-ASCII characters (in a template
 file)
 * The intermediate POT file is created (and preserved for examination)
 * When the POT file is created, the header `"Content-Type: text/plain;
 charset=?????\n"` is verified and it already has the `UFT-8` value for the
 charset.

 Am I missing something? How it comes the created POT file has a `"Content-
 Type: text/plain; charset=CHARSET\n"` header?
 * Is the fact tha OP is running on Windows?
 * Does this happen when extracting literal from .py files? Javascript?

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/072.ddd3336018e61aa55f8c7d5e10848b18%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to