Bug report #9097

Could't run the python script, when a multi-byte letter is included in file name

Added by kosuke ASAHI over 10 years ago. Updated over 10 years ago.

Assignee:Salvatore Larosa
Affected QGIS version:2.0.1 Regression?:No
Operating System:windows Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:17742


When run the python script which multi-byte letter is contained file name from python console editor, I/O error occur.
We Japanese community know we can run the script correctly if we change the code as following,

line : 584

- self.parent.pc.shell.runCommand(u"execfile(r'{0}')".format(filename))
+ self.parent.pc.shell.runCommand(u"execfile(u'{0}'.encode('sjis'))".format(filename.replace("\\\\",

But we don't know this is best way to solve this.
Please check this problem.

Tested QGIS 2.0 installed from OSGeo4W on Japanese locale Windows

Associated revisions

Revision f21562c8
Added by Salvatore Larosa over 10 years ago

[pyqgis-console] fixes #9097 (thanks to Minoru Akagi)


#1 Updated by Minoru Akagi over 10 years ago

The patch should be:

- self.parent.pc.shell.runCommand(u"execfile(r'{0}')".format(filename))
+ self.parent.pc.shell.runCommand(u"execfile(u'{0}'.encode('{1}'))".format(filename.replace("\\\\", "/"), sys.getfilesystemencoding()))

#2 Updated by Matthias Kuhn over 10 years ago

  • Assignee set to Salvatore Larosa

#3 Updated by Salvatore Larosa over 10 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF