Opened 11 years ago

Closed 9 years ago

#1004 closed defect (fixed)

WxGUI CMD fails if command contains non-latin letters

Reported by: marisn Owned by: martinl
Priority: major Milestone: 6.4.2
Component: wxGUI Version: svn-releasebranch64
Keywords: unicode, wingrass Cc: grass-dev@…
CPU: x86-32 Platform: MSWindows Vista

Description

If I enter some command in WxGUI CMD prompt that contains non-latin letters, I get ugly Python error:

Traceback (most recent call last):
  File "C:/Program
Files/GRASS-64-SVN/etc/wxpython/wxgui.py", line 462, in
OnRunCmd

cmd = shlex.split(str(cmdString))
UnicodeEncodeError
:
'ascii' codec can't encode character u'\u0160' in position
55: ordinal not in range(128)

Tested on WinGRASS WinGRASS-6.4.SVN-r41428-1 running Vista

Change History (10)

comment:1 Changed 11 years ago by martinl

Cc: martinl added
Keywords: unicode added; wxgui removed

The problem here is the fact that shlex does not support unicode...

http://docs.python.org/library/shlex.html

comment:2 in reply to:  1 Changed 11 years ago by martinl

Cc: grass-dev@… added; martinl removed
Owner: changed from grass-dev@… to martinl
Status: newassigned

Replying to martinl:

The problem here is the fact that shlex does not support unicode...

http://docs.python.org/library/shlex.html

Quick workaround implemented in r41459.

comment:3 Changed 11 years ago by marisn

WinGRASS-6.4.SVN-r41467-1

Exception in thread Thread-6:
Traceback (most recent call last):
  File "C:\OSGeo4W\apps\Python25\lib\threading.py", line
486, in __bootstrap_inner
    self.run()
  File "C:\Program
Files\GRASS-64-SVN\etc\wxpython\gui_modules\gcmd.py", line
539, in run
    shell=sys.platform=="win32")
  File "C:\Program
Files\GRASS-64-SVN\etc\wxpython\gui_modules\gcmd.py", line
139, in __init__
    targs[0] = map(utils.EncodeString, args[0])
  File "c:\osgeo4w\usr\src\grass64_release\dist.i686-pc-
mingw32\etc\wxpython\gui_modules\utils.py", line 345, in
EncodeString
    return string.encode(enc)
  File "C:\Program
Files\GRASS-64-SVN\Python25\lib\encodings\cp1257.py", line
12, in encode
    return
codecs.charmap_encode(input,errors,encoding_table)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in
position 0: ordinal not in range(128)
Exception
Traceback (most recent call last):
exceptions
  File "C:/Program
Files/GRASS-64-SVN/etc/wxpython/wxgui.py", line 471, in
OnRunCmd
.

AttributeError
self.goutput.RunCmd(cmd, switchPage=True)
:
  File "C:\Program
Files\GRASS-64-SVN\etc\wxpython\gui_modules\goutput.py",
line 377, in RunCmd
"'Popen' object has no attribute '_child_created'"

 in
stderr=self.cmd_stderr)
<bound method Popen.__del__ of <gui_modules.gcmd.Popen
object at 0x03F3B210>>
  File "C:\Program
Files\GRASS-64-SVN\etc\wxpython\gui_modules\gcmd.py", line
369, in __init__
 ignored

_("Error: ") + self.GetError()))
  File "C:\Program
Files\GRASS-64-SVN\etc\wxpython\gui_modules\gcmd.py", line
458, in GetError

return _("Unable to exectute command: '%s'") % '
'.join(self.cmd)
UnicodeDecodeError
:
'ascii' codec can't decode byte 0xe2 in position 3: ordinal
not in range(128)

comment:4 Changed 10 years ago by neteler

See also trac #995

comment:5 Changed 10 years ago by martinl

Please try out r45549 (trunk or devbr6)

comment:6 Changed 10 years ago by marisn

Still fails.

String for testing:

db.out.ogr input=bugsites dsn="C:\Users\tests\Documents\šaursliežu dzelzceļš\šaurā datubāze"

WinGRASS-6.5.SVN-r45558-1

Traceback (most recent call last):
  File "C:\Program Files\GRASS
6.5.SVN\etc\wxpython\gui_modules\prompt.py", line 1064, in
OnKeyPressed

cmd = map(utils.DecodeString, cmd)
  File "c:/osgeo4w/usr/src/grass6_devel/dist.i686-pc-
mingw32/etc/wxpython/gui_modules/utils.py", line 655, in
DecodeString
  File "C:\Program Files\GRASS
6.5.SVN\Python25\lib\encodings\utf_8.py", line 16, in decode

return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError
:
'utf8' codec can't decode bytes in position 29-32: invalid
data

comment:7 Changed 10 years ago by hellik

Milestone: 6.4.06.4.1

comment:8 Changed 9 years ago by neteler

Some decoding stuff has been backported to 6.4/6.5, is this still an issue?

comment:9 in reply to:  8 Changed 9 years ago by marisn

Milestone: 6.4.16.4.2

Replying to neteler:

Some decoding stuff has been backported to 6.4/6.5, is this still an issue?

Can't test it, as now it fails somewhere in parser with "Sorry <> is not a valid option". Will have to open a new ticket for it at first.

comment:10 Changed 9 years ago by marisn

Resolution: fixed
Status: assignedclosed

Works now for me on Linux with UTF-8 locale. Complaints about "not valid option" are another issue.

Note: See TracTickets for help on using tickets.