Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#31850 closed Cleanup/optimization (fixed)

test_extraction_warning (i18n.test_extraction.BasicExtractorTests) fails with xgettext 0.21.

Reported by: Michał Górny Owned by: Max Smolens
Component: Testing framework Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

After upgrading system gettext to 0.21, the following test started to fail:

======================================================================
FAIL: test_extraction_warning (i18n.test_extraction.BasicExtractorTests)
test xgettext warning about multiple bare interpolation placeholders
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.9/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/usr/lib/python3.9/unittest/case.py", line 593, in run
    self._callTestMethod(testMethod)
  File "/usr/lib/python3.9/unittest/case.py", line 550, in _callTestMethod
    method()
  File "/tmp/django/tests/i18n/test_extraction.py", line 233, in test_extraction_warning
    self.assertIn("code_sample.py:4", out.getvalue())
  File "/usr/lib/python3.9/unittest/case.py", line 1098, in assertIn
    self.fail(self._formatMessage(msg, standardMsg))
  File "/usr/lib/python3.9/unittest/case.py", line 670, in fail
    raise self.failureException(msg)
AssertionError: 'code_sample.py:4' not found in 'processing locale de\n'

I can reproduce the failure with django 2.2.15, 3.0.9 and git master (b68b8cb89abb35ff2152175ea540619ec384b1f4).

Change History (18)

comment:1 by Mariusz Felisiak, 4 years ago

Component: UncategorizedTesting framework
Easy pickings: set
Summary: test_extraction_warning (i18n.test_extraction.BasicExtractorTests) fails with gettext-0.21test_extraction_warning (i18n.test_extraction.BasicExtractorTests) fails with xgettext 0.21.
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

I confirmed test failure with xgettext 0.21, it passes with the version 0.19.8.1. We can skip this test on specific versions of xgettext. Do you know when exactly it stopped to warn about multiple bare placeholders? Changelog would be helpful.

Last edited 4 years ago by Mariusz Felisiak (previous) (diff)

comment:2 by Mariusz Felisiak, 4 years ago

We should use a message that will cause a xgettext warning in all versions, see #18479.

comment:3 by Sicong, 4 years ago

Owner: changed from nobody to Sicong
Status: newassigned

I'll try to work on this issue.

comment:4 by Sicong, 4 years ago

Owner: Sicong removed
Status: assignednew

I can also reproduce this error.
I looked a little bit into gettext's source code, under warn_format_string function in xg-message.c. Everything seems fine. I'm not sure why xgettext not giving this warning. I'll leave this to somebody with more experience.

comment:5 by Ira, 4 years ago

Owner: set to Ira
Status: newassigned

I will try to work on this issue.

Last edited 4 years ago by Ira (previous) (diff)

comment:6 by Ira, 4 years ago

Can someone above help me reproduce the error? Please let me know iraf333@…

comment:7 by Ira, 4 years ago

Owner: Ira removed
Status: assignednew

I am going to release this ticket

comment:8 by Max Smolens, 4 years ago

Owner: set to Max Smolens
Status: newassigned

comment:9 by Max Smolens, 4 years ago

Has patch: set

It looks like xgettext 0.21 has a bug where the "format string with unnamed arguments cannot be properly localized" warning is not displayed. I proposed a patch upstream and am awaiting confirmation from the maintainer.

Regardless, I created a patch to use a message that causes an xgettext warning in all versions, as suggested by comment:2.

comment:10 by Mariusz Felisiak, 4 years ago

Triage Stage: AcceptedReady for checkin

comment:11 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In 07a30f56:

Fixed #31850 -- Fixed BasicExtractorTests.test_extraction_warning with xgettext 0.21+.

"format string with unnamed arguments cannot be properly localized"
warning is not raised in xgettext 0.21+.

This patch uses a message that causes an xgettext warning regardless of
the version.

comment:12 by Michał Górny, 4 years ago

I can confirm that the patch fixes the issue for me. Thanks!

comment:13 by Michał Górny, 4 years ago

Would it be possible to backport this into 2.2, 3.0 and 3.1 branches?

comment:14 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In e707a1bd:

[3.1.x] Fixed #31850 -- Fixed BasicExtractorTests.test_extraction_warning with xgettext 0.21+.

"format string with unnamed arguments cannot be properly localized"
warning is not raised in xgettext 0.21+.

This patch uses a message that causes an xgettext warning regardless of
the version.

Backport of 07a30f561661efae1691ff45d10ec6014b395b58 from master

comment:15 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In c506639b:

[3.0.x] Fixed #31850 -- Fixed BasicExtractorTests.test_extraction_warning with xgettext 0.21+.

"format string with unnamed arguments cannot be properly localized"
warning is not raised in xgettext 0.21+.

This patch uses a message that causes an xgettext warning regardless of
the version.

Backport of 07a30f561661efae1691ff45d10ec6014b395b58 from master

comment:16 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In e893c0ad:

[2.2.x] Fixed #31850 -- Fixed BasicExtractorTests.test_extraction_warning with xgettext 0.21+.

"format string with unnamed arguments cannot be properly localized"
warning is not raised in xgettext 0.21+.

This patch uses a message that causes an xgettext warning regardless of
the version.

Backport of 07a30f561661efae1691ff45d10ec6014b395b58 from master

in reply to:  13 comment:17 by Mariusz Felisiak, 4 years ago

Replying to Michał Górny:

Would it be possible to backport this into 2.2, 3.0 and 3.1 branches?

Backported.

comment:18 by Michał Górny, 4 years ago

That was fast. Thank you!

Note: See TracTickets for help on using tickets.
Back to Top