Opened 7 years ago
Closed 7 years ago
#3508 closed defect (fixed)
grass start up: buggy to_text_string
Reported by: | martinl | Owned by: | |
---|---|---|---|
Priority: | blocker | Milestone: | 7.2.3 |
Component: | Startup | Version: | svn-trunk |
Keywords: | wingrass, unicode | Cc: | |
CPU: | Unspecified | Platform: | Unspecified |
Description
GRASS fails even start on Windows when username contains non-ascii characters
Traceback (most recent call last): File "C:\Program Files\GRASS GIS 7.4.0\etc\grass74.py", line 2003, in <module> main() File "C:\Program Files\GRASS GIS 7.4.0\etc\grass74.py", line 1854, in main set_paths(grass_config_dir=grass_config_dir) File "C:\Program Files\GRASS GIS 7.4.0\etc\grass74.py", line 620, in set_paths os.environ['MANPATH'] = to_text_string(addons_man_path) File "C:\Program Files\GRASS GIS 7.4.0\Python27\lib\os.py", line 420, in __setitem__ putenv(key, item) UnicodeEncodeError: 'ascii' codec can't encode character u'\u017e' in position 10: ordinal not in range(128) Press any key to continue . . .
When I change line source:grass/trunk/lib/init/grass.py#L620
os.environ['MANPATH'] = to_text_string(addons_man_path)
to
os.environ['MANPATH'] = addons_man_path
then GRASS starts and even MANPATH variable is set up correctly (including non-ascii characters). Function to_text_string
is apparently buggy. Tested on Czech (cp1250) Windows 8.1.
Change History (12)
comment:1 by , 7 years ago
Priority: | normal → blocker |
---|
comment:2 by , 7 years ago
comment:3 by , 7 years ago
Right. The code is similar to _get_encoding()/decode()/encode()
group in source:grass/trunk/lib/python/script/utils.py#L159 from r65787. Do these functions work for you (assuming you can get around the startup issue)? All is basically based around locale.getdefaultlocale()[1]
.
follow-up: 5 comment:4 by , 7 years ago
I think this is a classical case of it being better not to mess around with the original byte string. All we do is taking a string from an environment variable, adding two new path elements and putting it back into another environment variable:
addon_base = os.getenv('GRASS_ADDON_BASE') [...] addons_man_path = os.path.join(addon_base, 'docs', 'man') os.environ['MANPATH'] = to_text_string(addons_man_path)
Do we really have to worry about encoding/decoding in that context ?
follow-up: 6 comment:5 by , 7 years ago
Replying to mlennert:
Do we really have to worry about encoding/decoding in that context ?
Encoding/decoding doesn't seems to be needed in this case.
addons_man_path = os.path.join(addon_base, 'docs', 'man')
perfectly works on my testing computer.
comment:6 by , 7 years ago
follow-up: 9 comment:8 by , 7 years ago
to_text_string()
disabled in r72374. Planning backport to 7.4 and 7.2 branches, any objections?
comment:9 by , 7 years ago
comment:12 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fixed in all affected branches: grass74 and grass72.
to_text_string
has been introduced 3 years ago in r65780