Skip to content

Commit 577a72b

Browse files
committed
[pyqgis-console] more encoding fix.
1 parent d61cb25 commit 577a72b

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

‎python/console/console_editor.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ def runScriptCode(self):
576576
tmpFile = self.createTempFile()
577577
filename = tmpFile
578578

579-
self.parent.pc.shell.runCommand("execfile(r'{0}')".format(filename))
579+
self.parent.pc.shell.runCommand(u"execfile(r'{0}')".format(filename))
580580

581581
def runSelectedCode(self):
582582
cmd = self.selectedText()

‎python/console/console_sci.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import sys
3030
import os
3131
import code
32+
import codecs
3233

3334
from qgis.core import QgsApplication
3435
from ui_console_history_dlg import Ui_HistoryDialogPythonConsole
@@ -277,7 +278,7 @@ def updateHistory(self, command):
277278
def writeHistoryFile(self, fromCloseConsole=False):
278279
ok = False
279280
try:
280-
wH = open(_historyFile, 'w')
281+
wH = codecs.open(_historyFile, 'w', encoding='utf-8')
281282
for s in self.history:
282283
wH.write(s + '\n')
283284
ok = True
@@ -292,7 +293,7 @@ def writeHistoryFile(self, fromCloseConsole=False):
292293
def readHistoryFile(self):
293294
fileExist = QFile.exists(_historyFile)
294295
if fileExist:
295-
rH = open(_historyFile, 'r')
296+
rH = codecs.open(_historyFile, 'r', encoding='utf-8')
296297
for line in rH:
297298
if line != "\n":
298299
l = line.rstrip('\n')
@@ -309,7 +310,7 @@ def clearHistory(self, clearSession=False):
309310
return
310311
ok = False
311312
try:
312-
cH = open(_historyFile, 'w')
313+
cH = codecs.open(_historyFile, 'w', encoding='utf-8')
313314
ok = True
314315
except:
315316
raise

0 commit comments

Comments
 (0)