[GRASS-dev] g.mapsets: UnicodeDecodeError: 'utf8' codec can't decode bytes in position ...

Glynn Clements glynn at gclements.plus.com
Fri May 13 22:16:32 EDT 2011


Markus Neteler wrote:

> Hi,
> 
> I updated G6.4.svn (make distclean) and have g.mapsets failing (started with
> no parameters) with
> 
> UnicodeDecodeError: 'utf8' codec can't decode bytes in position
> 84665-84666: invalid data
> see
> http://pastebin.com/BT1cHMJZ

gui/wxpython/gui_modules/prompt.py:508

            fileHistory = codecs.open(os.path.join(env['GISDBASE'],
                                                   env['LOCATION_NAME'],
                                                   env['MAPSET'],
                                                   '.bash_history'),
                                      encoding = 'utf-8', mode = 'r')

This will result in the problem you describe if the .bash_history file
contains any non-UTF-8 data, which is a definite possibility
regardless of the user's locale settings.

I suggest adding errors='replace' or errors='ignore' when calling
codecs.open().

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list