Opened 8 years ago

Closed 5 years ago

#2886 closed defect (worksforme)

v.import/r.import: UnicodeEncodeError when path contains special characters

Reported by: mlennert Owned by: grass-dev@…
Priority: normal Milestone: 7.0.7
Component: Default Version: svn-trunk
Keywords: v.import r.import encoding Cc:
CPU: Unspecified Platform: Unspecified

Description

Trying to importing a file that resides in a path with special characters (accent in this case), I get the following errors.

In trunk:

> v.import input=/home/mlennert/Données/ne_110m_admin_0_countries/ne_110m_admin_0_countries.shp output=countries
Traceback (most recent call last):
  File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-gnu/scripts/v.import", line 284, in <module>
    options, flags = grass.parser()
  File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-gnu/etc/python/grass/script/core.py", line 719, in parser
    cmdline += [b'"' + encode(arg) + b'"' for arg in sys.argv[1:]]
  File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-gnu/etc/python/grass/script/utils.py", line 174, in encode
    return string.encode(enc)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 25: ordinal not in range(128)

In release70:

> v.import input=/home/mlennert/Données/ne_110m_admin_0_countries/ne_110m_admin_0_countries.shp output=countries
Traceback (most recent call last):
  File "/home/mlennert/SRC/GRASS/grass70_release/dist.x86_64-pc-linux-gnu/scripts/v.import", line 273, in <module>
    sys.exit(main())
  File "/home/mlennert/SRC/GRASS/grass70_release/dist.x86_64-pc-linux-gnu/scripts/v.import", line 158, in main
    f.write('GISDBASE: %s\n' % GISDBASE)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 29: ordinal not in range(128)

I get exactly the same errors with r.import.

Change History (6)

in reply to:  description comment:1 by mlennert, 8 years ago

Replying to mlennert:

Trying to importing a file that resides in a path with special characters (accent in this case), I get the following errors.

In trunk:

> v.import input=/home/mlennert/Données/ne_110m_admin_0_countries/ne_110m_admin_0_countries.shp output=countries
Traceback (most recent call last):
  File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-gnu/scripts/v.import", line 284, in <module>
    options, flags = grass.parser()
  File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-gnu/etc/python/grass/script/core.py", line 719, in parser
    cmdline += [b'"' + encode(arg) + b'"' for arg in sys.argv[1:]]
  File "/home/mlennert/SRC/GRASS/grass_trunk/dist.x86_64-pc-linux-gnu/etc/python/grass/script/utils.py", line 174, in encode
    return string.encode(enc)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 25: ordinal not in range(128)

In release70:

Correction: in release70 the below error is due to GISDBASE containing an accent, not because of the file path. When GISDBASE does not contain an accent, below import works, even if the path to the imported file contains an accent.

> v.import input=/home/mlennert/Données/ne_110m_admin_0_countries/ne_110m_admin_0_countries.shp output=countries
Traceback (most recent call last):
  File "/home/mlennert/SRC/GRASS/grass70_release/dist.x86_64-pc-linux-gnu/scripts/v.import", line 273, in <module>
    sys.exit(main())
  File "/home/mlennert/SRC/GRASS/grass70_release/dist.x86_64-pc-linux-gnu/scripts/v.import", line 158, in main
    f.write('GISDBASE: %s\n' % GISDBASE)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 29: ordinal not in range(128)

comment:2 by martinl, 8 years ago

Milestone: 7.0.47.0.5

comment:3 by annakrat, 8 years ago

Tested on Linux and it works for me in trunk and 7.0.5.

comment:4 by neteler, 8 years ago

Milestone: 7.0.57.0.6

comment:5 by neteler, 6 years ago

Milestone: 7.0.67.0.7

comment:6 by martinl, 5 years ago

Resolution: worksforme
Status: newclosed
Note: See TracTickets for help on using tickets.