[win32] unknown terminal encoding cp65001

Bug #1447145 reported by Alexander Belchenko
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
New
Undecided
Unassigned

Bug Description

On Windows7 I can force terminal to use utf-8 by setting it `chcp 65001`. Bazaar (I guess it's underlying python actually) does not understand it:

>chcp
Active code page: 65001

>bzr st
bzr: warning: unknown terminal encoding cp65001.
  Using encoding cp1251 instead.
bzr: warning: unknown terminal encoding cp65001.
  Using encoding cp1251 instead.

That's because python still can't decide whether it should treat cp65001 as utf-8. http://bugs.python.org/issue6058#msg97731

Related SO topic: http://stackoverflow.com/questions/878972/windows-cmd-encoding-change-causes-python-crash

From answer http://stackoverflow.com/a/3259271/65736 it's enough to put this at the beginning of the bzr script:

import codecs
codecs.register(lambda name: codecs.lookup('utf-8') if name == 'cp65001' else None)

(I've tried to put this to simple plugin, but it still not work as expected, see below).

Or another way is from answer http://stackoverflow.com/a/12834315/65736

> chcp 65001
> set PYTHONIOENCODING=utf-8

(This does not help either).

Also with the first trick (adjust codecs table) bzr unable to add unicode files, there is internal traceback:

Wed 2015-04-22 15:23:14 +0300
0.070 bazaar version: 2.5.1
0.070 bzr arguments: [u'add']
0.070 looking for plugins in C:\work\Bazaar\plugins
0.080 looking for plugins in C:/Program Files (x86)/Bazaar/plugins
0.080 Plugin name explorer already loaded
0.080 Plugin name fastimport already loaded
0.080 Plugin name qbzr already loaded
0.090 encoding stdout as sys.stdout encoding 'cp65001'
0.120 opening working tree 'C:/work/Bazaar/plugins/cp65001'
0.150 skip control directory '.bzr'
0.160 Transferred: 0kB (0.0kB/s r:0kB w:0kB)
0.160 Traceback (most recent call last):
  File "bzrlib\commands.pyo", line 920, in exception_to_return_code
  File "bzrlib\commands.pyo", line 1131, in run_bzr
  File "bzrlib\commands.pyo", line 673, in run_argv_aliases
  File "bzrlib\commands.pyo", line 695, in run
  File "bzrlib\cleanup.pyo", line 136, in run_simple
  File "bzrlib\cleanup.pyo", line 166, in _do_with_cleanups
  File "bzrlib\builtins.pyo", line 847, in run
  File "bzrlib\mutabletree.pyo", line 52, in tree_write_locked
  File "bzrlib\mutabletree.pyo", line 453, in smart_add
  File "bzrlib\mutabletree.pyo", line 764, in add
  File "bzrlib\mutabletree.pyo", line 626, in _add_one_and_parent
  File "bzrlib\add.pyo", line 57, in __call__
  File "bzrlib\ui\text.pyo", line 669, in write
  File "codecs.pyo", line 352, in write
IOError: [Errno 0] Error

0.170 return code 3

Without changing codecs lookup it works but does not print to console desired output, because bzr forces cp1251.

C:\work\Bazaar\plugins\cp65001>bzr add
bzr: warning: unknown terminal encoding cp65001.
  Using encoding cp1251 instead.
bzr: warning: unknown terminal encoding cp65001.
  Using encoding cp1251 instead.
adding __init__.py
adding "����.txt"

Really really strange.

Jelmer Vernooij (jelmer)
tags: added: check-for-breezy
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.