Bug 159978

Summary: devel/bazaar-ng 2.4.0: Viewing help for subcommands results in an error
Product: Ports & Packages Reporter: Dean Matzkov <bapabooiee>
Component: Individual Port(s)Assignee: Philippe Audeoud <jadawin>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
patch-bzrlib_i18n.py none

Description Dean Matzkov 2011-08-22 00:10:08 UTC
When trying to view help text for any of bzr's subcommands, it errors out like so:


---SNIP---

bzr: ERROR: exceptions.AttributeError: 'NoneType' object has no attribute 'split'

Traceback (most recent call last):
  File "/usr/local/lib/python2.6/site-packages/bzrlib/commands.py", line 946, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/usr/local/lib/python2.6/site-packages/bzrlib/commands.py", line 1150, in run_bzr
    ret = run(*run_argv)
  File "/usr/local/lib/python2.6/site-packages/bzrlib/commands.py", line 674, in run_argv_aliases
    self.outf.write(self.get_help_text())
  File "/usr/local/lib/python2.6/site-packages/bzrlib/commands.py", line 492, in get_help_text
    i18n.install()  # Install i18n only for get_help_text for now.
  File "/usr/local/lib/python2.6/site-packages/bzrlib/i18n.py", line 80, in install
    languages=lang.split(':'),
AttributeError: 'NoneType' object has no attribute 'split'

bzr 2.4.0 on python 2.6.7 (FreeBSD-8.2-RELEASE-i386-32bit-ELF)
arguments: ['/usr/local/bin/bzr', 'update', '--help']
plugins: bash_completion[2.4.0], changelog_merge[2.4.0], git[0.6.1],
    launchpad[2.4.0], netrc_credential_store[2.4.0], news_merge[2.4.0],
    weave_fmt[2.4.0]
encoding: 'US-ASCII', fsenc: 'US-ASCII', lang: None

----SNIP----


This only occurs with bzr-2.4.0, which is the current version in the Ports tree. Downgrading to a previous version (such as v2.3.0) does not exhibit this problem.

How-To-Repeat: $ cd /usr/ports/devel/bazaar-ng
# make install
$ bzr update --help
Comment 1 R.Mahmatkhanov 2011-08-23 09:05:06 UTC
Hi, Dean.

I can't reproduce it here:

"""
mrk@smeshariki2$ bzr --version
Bazaar (bzr) 2.4.0
   Python interpreter: /usr/local/bin/python2.7 2.7.2
   Python standard library: /usr/local/lib/python2.7
   Platform: FreeBSD-9.0-BETA1-i386-32bit-ELF
   bzrlib: /usr/local/lib/python2.7/site-packages/bzrlib
   Bazaar configuration: /root/.bazaar
   Bazaar log file: /root/.bzr.log
[skip]
mrk@smeshariki2$ bzr update --help
Purpose: Update a tree to have the latest code committed to its branch.
Usage:   bzr update [DIR]

Options:
[skip]
"""

does `bzr help update` work for you? If it's not, can you please show 
what locale you are using:

mrk@smeshariki2$ env | grep LANG
LANG=ru_RU.UTF-8

Try to patch your /usr/local/lib/python2.6/site-packages/bzrlib/i18n.py 
like this and show me the output of the bzr update --help:

  73 def install(lang=None):
  74     global _translations
  75     print("Lang before anything: ", lang)
  76     if lang is None:
  77         lang = _get_current_locale()
  78     print("Lang before get_current_locale: ", lang)
  79     _translations = _gettext.translation(
  80             'bzr',
  81             localedir=_get_locale_dir(),
  82             languages=lang.split(':'),
  83             fallback=True)

-- 
Regards,
Ruslan

Tinderboxing kills... the drives.
Comment 2 R.Mahmatkhanov 2011-08-23 10:10:59 UTC
Hmm, i can reproduce it like this:

mrk@smeshariki2$ unsetenv LANG
mrk@smeshariki2$ bzr help update
('Lang before anything: ', None)
('Lang before get_current_locale: ', None)
bzr: ERROR: exceptions.AttributeError: 'NoneType' object has no 
attribute 'split'

Traceback (most recent call last):
   File "/usr/local/lib/python2.7/site-packages/bzrlib/commands.py", 
line 946, in exception_to_return_code
     return the_callable(*args, **kwargs)
   File "/usr/local/lib/python2.7/site-packages/bzrlib/commands.py", 
line 1150, in run_bzr
     ret = run(*run_argv)
   File "/usr/local/lib/python2.7/site-packages/bzrlib/commands.py", 
line 699, in run_argv_aliases
     return self.run(**all_cmd_args)
   File "/usr/local/lib/python2.7/site-packages/bzrlib/commands.py", 
line 721, in run
     return self._operation.run_simple(*args, **kwargs)
   File "/usr/local/lib/python2.7/site-packages/bzrlib/cleanup.py", line 
135, in run_simple
     self.cleanups, self.func, *args, **kwargs)
   File "/usr/local/lib/python2.7/site-packages/bzrlib/cleanup.py", line 
165, in _do_with_cleanups
     result = func(*args, **kwargs)
   File "/usr/local/lib/python2.7/site-packages/bzrlib/commands.py", 
line 1165, in ignore_pipe
     result = func(*args, **kwargs)
   File "/usr/local/lib/python2.7/site-packages/bzrlib/builtins.py", 
line 4444, in run
     bzrlib.help.help(topic)
   File "/usr/local/lib/python2.7/site-packages/bzrlib/help.py", line 
51, in help
     outfile.write(source.get_help_text(shadowed_terms))
   File "/usr/local/lib/python2.7/site-packages/bzrlib/commands.py", 
line 492, in get_help_text
     i18n.install()  # Install i18n only for get_help_text for now.
   File "/usr/local/lib/python2.7/site-packages/bzrlib/i18n.py", line 
82, in install
     languages=lang.split(':'),
AttributeError: 'NoneType' object has no attribute 'split'

bzr 2.4.0 on python 2.7.2 (FreeBSD-9.0-BETA1-i386-32bit-ELF)
arguments: ['/usr/local/bin/bzr', 'help', 'update']
plugins: bash_completion[2.4.0], changelog_merge[2.4.0], launchpad[2.4.0],
     netrc_credential_store[2.4.0], news_merge[2.4.0], weave_fmt[2.4.0]
encoding: 'US-ASCII', fsenc: 'US-ASCII', lang: None

*** Bazaar has encountered an internal error.  This probably indicates a
     bug in Bazaar.  You can help us fix it by filing a bug report at
         https://bugs.launchpad.net/bzr/+filebug
     including this traceback and a description of the problem.


So the workaround is to set LANG variable in your environment, but it's 
obviously a bzr bug, since it should fallback to C by default.

-- 
Regards,
Ruslan

Tinderboxing kills... the drives.
Comment 3 R.Mahmatkhanov 2011-08-23 10:21:50 UTC
So i sent upstream bug report:
https://bugs.launchpad.net/bzr/+bug/831852

-- 
Regards,
Ruslan

Tinderboxing kills... the drives.
Comment 4 R.Mahmatkhanov 2011-08-23 19:27:33 UTC
This upstream patch works for me:
http://bazaar.launchpad.net/~jelmer/bzr/fix-i18n/revision/6026

We can place patch attached into devel/bazaar-ng/files until bzr 2.5 
(that contains this fix) will not be released.

-- 
Regards,
Ruslan

Tinderboxing kills... the drives.
Comment 5 Philippe Audeoud freebsd_committer freebsd_triage 2011-09-09 09:56:13 UTC
Responsible Changed
From-To: freebsd-ports-bugs->jadawin

I'll take it.
Comment 6 Philippe Audeoud freebsd_committer freebsd_triage 2011-09-09 09:56:35 UTC
State Changed
From-To: open->closed

Supersed by ports/160583.