Opened 9 years ago

Last modified 7 years ago

#2050 new defect

After GRASS started xml.etree.ElementTree raises ParseError when clicking any GUI element on Win 7 Simplified Chinese

Reported by: lazywalking Owned by: grass-dev@…
Priority: major Milestone: 6.4.6
Component: wxGUI Version: unspecified
Keywords: chinese, windows 7, gui, encoding Cc:
CPU: Unspecified Platform: MSWindows 7


I'm using Win7 Simplified Chinese, with GRASS 6.4.3RC4 installed. After GRASS started successfully, it raises ParseError in xml.etree.ElementTree module when I click any tool or menu in Layer Manager window. For Example, if I click "Add vector map layer" tool, error messages below will display in Command Console, and d.vect setting window can't open.

Traceback (most recent call last):

File "d:\GRASS\etc\wxpython\lmgr\", line 1563, in



File "d:\GRASS\etc\wxpython\lmgr\", line 924,

in AddLayer

self.PropertiesDialog(layer, show = True)

File "d:\GRASS\etc\wxpython\lmgr\", line 1036,

in PropertiesDialog

completed = (self.GetOptData,layer,params))

File "d:\GRASS\etc\wxpython\gui_core\", line 1871,

in ParseCommand

blackList = _blackList)

File "d:\GRASS\etc\python\grass\script\", line 470,

in parse_interface

tree = etree.fromstring(get_interface_description(name))

File "d:\GRASS\Python27\lib\xml\etree\",

line 1300, in XML


File "d:\GRASS\Python27\lib\xml\etree\",

line 1642, in feed


File "d:\GRASS\Python27\lib\xml\etree\",

line 1506, in _raiseerror

raise err xml.etree.ElementTree . ParseError : unknown encoding: line 1, column 30

Finally I find that the bug is in file with lines 460-470.

    enc = locale.getdefaultlocale()[1]
    if enc and enc.lower() == 'cp932':
        p = re.compile('encoding="' + enc + '"', re.IGNORECASE)        
        tree = etree.fromstring(p.sub('encoding="utf-8"',
       tree = etree.fromstring(get_interface_description(name))

On my PC, enc is 'cp936', but the encoding of string returned by get_interface_description(name) is 'gbk'. I replace first two sentences with

    enc = locale.encodings.aliases.aliases[locale.getdefaultlocale()[1]]
    if enc and enc.lower() != 'utf-8':

. It works fine on my PC. But I don't know whether it succeeds in other conditions.

Change History (2)

comment:1 by improgrammer, 9 years ago

The same question as 1941

comment:2 by neteler, 7 years ago

Note: See TracTickets for help on using tickets.