`bzr add file1 file2` in non-ascii folder fails, but `bzr add file1` works

Bug #686611 reported by Alexander Belchenko on 2010-12-07
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Martin Packman
Martin Packman
Martin Packman
Martin Packman

Bug Description

bzr 2.2.1 @ windows. Very weird behavior:

C:\work\MyCode\Визуализатор\Protocol>bzr add apvs-protocol.txt Makefile
bzr: ERROR: exceptions.UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 15: ordinal not in range(128)

Traceback (most recent call last):
  File "bzrlib\commands.pyo", line 912, in exception_to_return_code
  File "bzrlib\commands.pyo", line 1112, in run_bzr
  File "bzrlib\commands.pyo", line 690, in run_argv_aliases
  File "bzrlib\commands.pyo", line 705, in run
  File "bzrlib\cleanup.pyo", line 135, in run_simple
  File "bzrlib\cleanup.pyo", line 165, in _do_with_cleanups
  File "bzrlib\builtins.pyo", line 690, in run
  File "bzrlib\mutabletree.pyo", line 50, in tree_write_locked
  File "bzrlib\mutabletree.pyo", line 421, in smart_add
  File "bzrlib\osutils.pyo", line 500, in normalizepath
  File "bzrlib\osutils.pyo", line 343, in _win32_pathjoin
  File "ntpath.pyo", line 108, in join
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 15: ordinal not in range(128)

bzr 2.2.1 on python 2.6.4 (Windows-XP-5.1.2600-SP3)
arguments: ['C:\\Program Files\\Bazaar\\bzr.EXE', 'add', 'apvs-protocol.txt', 'Makefile']
encoding: 'cp1251', fsenc: 'mbcs', lang: None
  acad C:\work\Bazaar\plugins\acad [0.8.0]
  bzrtools C:\Program Files\Bazaar\plugins\bzrtools [2.2.0]
  colo C:\work\Bazaar\plugins\colo [0.2.1dev]
  explorer C:\work\Bazaar\plugins\explorer [1.1.2dev]
  format1 C:\work\Bazaar\plugins\format1 [unknown]
  kftp C:\work\Bazaar\plugins\kftp [unknown]
  launchpad C:\Program Files\Bazaar\plugins\launchpad [2.2.1]
  qbzr C:\work\Bazaar\plugins\qbzr [0.20.0dev1]
  rewrite C:\Program Files\Bazaar\plugins\rewrite [0.6.1]
  scmproj C:\work\Bazaar\plugins\scmproj [0.6.1]
  x_bit C:\work\Bazaar\plugins\x_bit [1.0.0]

*** 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
    including this traceback and a description of the problem.

But adding the same files one by one works:

C:\work\MyCode\Визуализатор\Protocol>bzr add Makefile
adding Makefile

C:\work\MyCode\Визуализатор\Protocol>bzr add apvs-protocol.txt
adding apvs-protocol.txt

Related branches

summary: - `bzr add file1 file2` in non-ascii folder fails
+ `bzr add file1 file2` in non-ascii folder fails, but `bzr add file1`
+ works
Martin Packman (gz) wrote :

Fun bug. This is a regression from the fix for bug 192859 specifically in r4634.159.8 on trunk. The problem only manifests with relative paths, and as noted only with more than once filename.

The basic issue is in trying to turn a (unicode) relative path into an absolute path with a (bytestring) cwd.

In cmd_add.run:
    tree, file_list = tree_files_for_add(file_list)
In tree_files_for_add:
    file_list = file_list[:]
    file_list[0] = tree.abspath(relpath)

Which explains why passing one file at a time works, the first file given is preabsoluted.

In MutableTree.smart_add:
    # expand any symlinks in the directory part, while leaving the
    # filename alone
    file_list = map(osutils.normalizepath, file_list)

There's the boom on Python 2.5 or earlier, that goes down to os.path.abspath which dies on a unicode argument and non-ascii cwd:

Changed in bzr:
importance: Undecided → Low
status: New → Confirmed
Martin Packman (gz) wrote :

...and you still get it on 2.6 because _win32_ prefixed osutils versions screw things up anyway.

Martin Packman (gz) wrote :

...fixed in 2.6.5 to recorrect myself, though I wasn't really wrong about the screwing up either.

Martin Packman (gz) wrote :

Okay, I've got this, though I'll need someone to tell me what the intended function of osutils.normalizepath actually is.

Changed in bzr:
assignee: nobody → Martin [gz] (gz)
milestone: none → 2.3b5
Vincent Ladeuil (vila) on 2010-12-17
Changed in bzr:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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