Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #910 from bmispelon/ticket-20058

Fix #20058: Make compilemessages use stdout instead of stderr.
  • Loading branch information...
commit 74a80a5169a1c870e6c2f78a18f67b366b0f60de 2 parents d7c83f2 + d5683bd
@claudep claudep authored
View
6 django/core/management/commands/compilemessages.py
@@ -15,7 +15,7 @@ def has_bom(fn):
sample.startswith(codecs.BOM_UTF16_LE) or \
sample.startswith(codecs.BOM_UTF16_BE)
-def compile_messages(stderr, locale=None):
+def compile_messages(stdout, locale=None):
program = 'msgfmt'
if find_command(program) is None:
raise CommandError("Can't find %s. Make sure you have GNU gettext tools 0.15 or newer installed." % program)
@@ -41,7 +41,7 @@ def compile_messages(stderr, locale=None):
for f in filenames:
if not f.endswith('.po'):
continue
- stderr.write('processing file %s in %s\n' % (f, dirpath))
+ stdout.write('processing file %s in %s\n' % (f, dirpath))
fn = os.path.join(dirpath, f)
if has_bom(fn):
raise CommandError("The %s file has a BOM (Byte Order Mark). Django only supports .po files encoded in UTF-8 and without any BOM." % fn)
@@ -68,4 +68,4 @@ class Command(BaseCommand):
def handle(self, **options):
locale = options.get('locale')
- compile_messages(self.stderr, locale=locale)
+ compile_messages(self.stdout, locale=locale)
View
12 tests/i18n/commands/compilation.py
@@ -29,7 +29,7 @@ class PoFileTests(MessageCompilationTests):
def test_bom_rejection(self):
with self.assertRaises(CommandError) as cm:
- call_command('compilemessages', locale=self.LOCALE, stderr=StringIO())
+ call_command('compilemessages', locale=self.LOCALE, stdout=StringIO())
self.assertIn("file has a BOM (Byte Order Mark)", cm.exception.args[0])
self.assertFalse(os.path.exists(self.MO_FILE))
@@ -45,7 +45,7 @@ def setUp(self):
self.addCleanup(os.unlink, os.path.join(test_dir, self.MO_FILE))
def test_percent_symbol_in_po_file(self):
- call_command('compilemessages', locale=self.LOCALE, stderr=StringIO())
+ call_command('compilemessages', locale=self.LOCALE, stdout=StringIO())
self.assertTrue(os.path.exists(self.MO_FILE))
@@ -63,7 +63,7 @@ def setUp(self):
@override_settings(LOCALE_PATHS=(os.path.join(test_dir, 'locale'),))
def test_percent_symbol_escaping(self):
from django.template import Template, Context
- call_command('compilemessages', locale=self.LOCALE, stderr=StringIO())
+ call_command('compilemessages', locale=self.LOCALE, stdout=StringIO())
with translation.override(self.LOCALE):
t = Template('{% load i18n %}{% trans "Looks like a str fmt spec %% o but shouldn\'t be interpreted as such" %}')
rendered = t.render(Context({}))
@@ -88,12 +88,12 @@ def setUp(self):
self.addCleanup(self.rmfile, os.path.join(localedir, self.MO_FILE_FR))
def test_one_locale(self):
- call_command('compilemessages', locale='hr', stderr=StringIO())
+ call_command('compilemessages', locale='hr', stdout=StringIO())
self.assertTrue(os.path.exists(self.MO_FILE_HR))
def test_multiple_locales(self):
- call_command('compilemessages', locale=['hr', 'fr'], stderr=StringIO())
+ call_command('compilemessages', locale=['hr', 'fr'], stdout=StringIO())
self.assertTrue(os.path.exists(self.MO_FILE_HR))
self.assertTrue(os.path.exists(self.MO_FILE_FR))
@@ -110,4 +110,4 @@ def setUp(self):
def test_error_reported_by_msgfmt(self):
with self.assertRaises(CommandError):
- call_command('compilemessages', locale=self.LOCALE, stderr=StringIO())
+ call_command('compilemessages', locale=self.LOCALE, stdout=StringIO())
Please sign in to comment.
Something went wrong with that request. Please try again.