bzrlib.tests.test_diff.TestDiff failure in German locale

Bug #56307 reported by Martin Pitt
2
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Low
John A Meinel

Bug Description

Hi!

On current Ubuntu Edgy I get one failure in the test suite when running under de_DE.UTF-8 locale:

======================================================================
ERROR: test_external_diff_binary (bzrlib.tests.test_diff.TestDiff)

vvvv[log from bzrlib.tests.test_diff.TestDiff.test_external_diff_binary]------

^^^^[log from bzrlib.tests.test_diff.TestDiff.test_external_diff_binary]------
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/martin/ubuntu/bzr/bzr-0.9/bzrlib/tests/test_diff.py", line 113, in test_external_diff_binary
    lines = external_udiff_lines(['\x00foobar\n'], ['foo\x00bar\n'])
  File "/home/martin/ubuntu/bzr/bzr-0.9/bzrlib/tests/test_diff.py", line 43, in external_udiff_lines
    external_diff('old', old, 'new', new, output, diff_opts=['-u'])
  File "/home/martin/ubuntu/bzr/bzr-0.9/bzrlib/diff.py", line 172, in external_diff
    raise BzrError('external diff failed with exit code 2;'
BzrError: external diff failed with exit code 2; command: ['diff', '--label', 'old', '/tmp/bzr-diff-old-s_BDuC', '--label', 'new', '/tmp/bzr-diff-new-rUF2v_', '--binary', '-u']

It works fine under C.

Related branches

Revision history for this message
Martin Pitt (pitti) wrote :

in case it matters, this happens while doing 'make check'.

Revision history for this message
John A Meinel (jameinel) wrote :

It actually sounds like 'diff' itself is unhappy with LANG=de_DE.UTF-8.
oh wait... I know what is wrong.

We are reading the output of diff, to see *why* it is unhappy. And if 'diff' says 'Binary files differ' we just absorb the error.
Under LANG=de_DE it must give an i18n error message.

What we are doing is already a hack-around. 'diff' returns an exit code of 2 if anything goes wrong (bad parameters, binary files, etc). We didn't want to always swallow exit = 2, in case there was a real error. So I check the first line and see if it says 'Binary files ... differ'

So one solution would be to set LANG=C before calling diff. Though if there are any real errors, it would return an english message, rather than returning a i18n one.

Any preferences / suggestions?

(It would be trivial to fix the test to pass, but what is the real fix?)

Changed in bzr:
importance: Untriaged → Low
status: Unconfirmed → Confirmed
Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 56307] Re: bzrlib.tests.test_diff.TestDiff failure in German locale

On Mon, 2006-08-14 at 21:09 +0000, John A Meinel wrote:

> So one solution would be to set LANG=C before calling diff. Though if
> there are any real errors, it would return an english message, rather
> than returning a i18n one.

From the info documentation for diff -
"An exit status of 0 means no differences were found, 1 means some
differences were found, and 2 means trouble."

So I think:
set LANG=C

on error invoke it again with the native LANG value, and require that it
fail again :).

Rob

--
GPG key available at: <http://www.robertcollins.net/keys.txt>.

Revision history for this message
John A Meinel (jameinel) wrote :

The associated branch should have a fix, using Roberts suggestion of running 'diff' 2 times on an error.

Changed in bzr:
assignee: nobody → jameinel
status: Confirmed → Fix Committed
John A Meinel (jameinel)
Changed in bzr:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.