[processing] small fix for non-ascii string (fixes #9175)

This commit is contained in:
Salvatore Larosa 2014-01-11 15:01:15 +01:00
parent 1bca310862
commit d04239d70b
2 changed files with 6 additions and 5 deletions

View File

@ -26,6 +26,8 @@ __copyright__ = '(C) 2012, Alexander Bruy'
__revision__ = '$Format:%H$'
import pickle
import codecs
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
@ -152,12 +154,11 @@ class ScriptEditorDialog(QDialog, Ui_DlgScriptEditor):
if self.alg is not None:
self.alg.script = text
try:
fout = open(self.filename, 'w')
fout.write(text)
fout.close()
with codecs.open(self.filename, 'w', encoding='utf-8') as fout:
fout.write(text)
except IOError:
QMessageBox.warning(self, self.tr('I/O error'),
self.tr('Unable to save edits. Reason:\n %1')
self.tr('Unable to save edits. Reason:\n %s')
% unicode(sys.exc_info()[1]))
return
self.update = True

View File

@ -254,7 +254,7 @@ class ScriptAlgorithm(GeoAlgorithm):
out.setValue(ns[out.name])
def helpFile(self):
helpfile = unicode(self.descriptionFile) + '.help'
helpfile = self.descriptionFile + '.help'
if os.path.exists(helpfile):
h2h = Help2Html()
return h2h.getHtmlFile(self, helpfile)