tab completion in shell (bzrtools) fails - WinXP

Bug #431241 reported by David Roberts
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
BzrTools
Fix Released
Undecided
Unassigned

Bug Description

Tab completion in shell, from bzrtools, has some problems. Tested on Win XP.

The following demonstrates. Error reported related to readline, and previous
command - if any - is executed instead of the intended one. Notation "<TAB>" used
to show when Tab key on keyboard was entered.

H:\David\TryBzrExpl\shared repo>bzr shell
bzr> ver<TAB>Readline internal error
Traceback (most recent call last):
  File "pyreadline\console\console.pyo", line 671, in hook_wrapper_23
  File "pyreadline\rlmain.pyo", line 342, in readline
  File "pyreadline\modes\emacs.pyo", line 133, in readline
  File "pyreadline\modes\emacs.pyo", line 90, in _readline_from_keyboard
  File "pyreadline\modes\basemode.pyo", line 190, in complete
  File "pyreadline\modes\basemode.pyo", line 128, in _get_completions
UnicodeDecodeError: 'ascii' codec can't decode byte 0xa0 in position 6: ordinal not in range(128)
bzr> version [[Tab-completion NOT used on this line]]
Bazaar (bzr) 2.0rc2
  Python interpreter: C:\Added Program Files\Bazaar\python25.dll 2.5.4
  Python standard library: C:\Added Program Files\Bazaar\lib\library.zip
  Platform: Windows-XP-5.1.2600-SP1
  bzrlib: C:\Added Program Files\Bazaar\lib\library.zip\bzrlib
  Bazaar configuration: C:\Documents and Settings\David\Application Data\bazaar\2.0
  Bazaar log file: C:\Documents and Settings\David\My Documents\.bzr.log

Copyright 2005, 2006, 2007, 2008, 2009 Canonical Ltd.
http://bazaar-vcs.org/

bzr comes with ABSOLUTELY NO WARRANTY. bzr is free software, and
you may use, modify and redistribute it under the terms of the GNU
General Public License version 2 or later.

bzr> plug<TAB>Readline internal error [[NOTE that bzr executes 'version' instead of 'plugins']]
Traceback (most recent call last):
  File "pyreadline\console\console.pyo", line 671, in hook_wrapper_23
  File "pyreadline\rlmain.pyo", line 342, in readline
  File "pyreadline\modes\emacs.pyo", line 133, in readline
  File "pyreadline\modes\emacs.pyo", line 90, in _readline_from_keyboard
  File "pyreadline\modes\basemode.pyo", line 190, in complete
  File "pyreadline\modes\basemode.pyo", line 128, in _get_completions
UnicodeDecodeError: 'ascii' codec can't decode byte 0xa0 in position 6: ordinal not in range(128)
Bazaar (bzr) 2.0rc2
  Python interpreter: C:\Added Program Files\Bazaar\python25.dll 2.5.4
  Python standard library: C:\Added Program Files\Bazaar\lib\library.zip
  Platform: Windows-XP-5.1.2600-SP1
  bzrlib: C:\Added Program Files\Bazaar\lib\library.zip\bzrlib
  Bazaar configuration: C:\Documents and Settings\David\Application Data\bazaar\2.0
  Bazaar log file: C:\Documents and Settings\David\My Documents\.bzr.log

Copyright 2005, 2006, 2007, 2008, 2009 Canonical Ltd.
http://bazaar-vcs.org/

bzr comes with ABSOLUTELY NO WARRANTY. bzr is free software, and
you may use, modify and redistribute it under the terms of the GNU
General Public License version 2 or later.

bzr>

David Roberts (smartgpx)
description: updated
Vincent Ladeuil (vila)
affects: bzr → bzrtools
Revision history for this message
John A Meinel (jameinel) wrote :

So I tracked down the cause. It seems to be this line in bzrtools:
  === modified file 'shell.py'
--- shell.py 2008-02-13 04:58:32 +0000
+++ shell.py 2009-09-22 18:09:52 +0000
@@ -99,7 +99,7 @@
         self.identchars += '-'
         ensure_config_dir_exists()
         self.history_file = osutils.pathjoin(config_dir(), 'shell-history')
- readline.set_completer_delims(string.whitespace)
+ readline.set_completer_delims(string.whitespace[:-1])
         if os.access(self.history_file, os.R_OK) and \
             os.path.isfile(self.history_file):
             readline.read_history_file(self.history_file)

I don't know 100% how to trigger it, but I know we have this comment in 'osutils.py':
def contains_whitespace(s):
    """True if there are any whitespace characters in s."""
    # string.whitespace can include '\xa0' in certain locales, because it is
    # considered "non-breaking-space" as part of ISO-8859-1. But it
    # 1) Isn't a breaking whitespace
    # 2) Isn't one of ' \t\r\n' which are characters we sometimes use as
    # separators
    # 3) '\xa0' isn't unicode safe since it is >128.

    # This should *not* be a unicode set of characters in case the source
    # string is not a Unicode string. We can auto-up-cast the characters since
    # they are ascii, but we don't want to auto-up-cast the string in case it
    # is utf-8
    for ch in ' \t\n\r\v\f':
        if ch in s:
            return True
    else:
        return False

What is really really weird is that if I do:

  python -c "import string; print repr(string.whitespace)"
It *doesn't* contain '\xa0'

But if i do:
  bzr shell

And change shell.py to read:
+ print repr(string.whitespace)
         readline.set_completer_delims(string.whitespace)

It *does* contain '\xa0'.

But I haven't figured out anywhere that actually mutates the value...

Revision history for this message
Aaron Bentley (abentley) wrote :

I can't reproduce this bug in linux. It may be platform-dependent, or related to other plugins that the user has installed. bzr-gtk, for example, used alter the default encoding to utf-8.

Aaron Bentley (abentley)
Changed in bzrtools:
status: New → 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.