Bug report #9097

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

Added by kosuke ASAHI about 7 years ago. Updated about 7 years ago.

Status:Closed
Priority:Normal
Assignee:Salvatore Larosa
Category:-
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

Description

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,

qgis\\python\\console\\console_editor.py
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 about 7 years ago

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

History

#1 Updated by Minoru Akagi about 7 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 about 7 years ago

  • Assignee set to Salvatore Larosa

#3 Updated by Salvatore Larosa about 7 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF