Skip to content

Commit

Permalink
[python console] remove 'u' prefixes from strings (fix #18171)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Feb 23, 2018
1 parent a554409 commit 7823025
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 17 deletions.
2 changes: 0 additions & 2 deletions python/console/console.py
Expand Up @@ -18,8 +18,6 @@
***************************************************************************/
Some portions of code were taken from https://code.google.com/p/pydee/
"""
from builtins import str
from builtins import range
import os

from qgis.PyQt.QtCore import Qt, QTimer, QCoreApplication, QSize, QByteArray, QFileInfo, QUrl, QDir
Expand Down
4 changes: 2 additions & 2 deletions python/console/console_compile_apis.py
Expand Up @@ -64,7 +64,7 @@ def _preparationFinished(self):
rslt = self.tr("Error")
if prepd:
rslt = QCoreApplication.translate("PythonConsole", "Saved")
self.ui.label.setText(u'{0} {1}'.format(self.ui.label.text(), rslt))
self.ui.label.setText('{0} {1}'.format(self.ui.label.text(), rslt))
self._api = None
self.ui.progressBar.setVisible(False)
self.ui.buttonBox.button(QDialogButtonBox.Cancel).setText(
Expand All @@ -73,7 +73,7 @@ def _preparationFinished(self):

def prepareAPI(self):
# self.ui.textEdit_Qsci.setLexer(0)
exec(u'self.qlexer = {0}(self.ui.textEdit_Qsci)'.format(self._api_lexer))
exec('self.qlexer = {0}(self.ui.textEdit_Qsci)'.format(self._api_lexer))
# self.ui.textEdit_Qsci.setLexer(self.qlexer)
self._api = QsciAPIs(self.qlexer)
self._api.apiPreparationFinished.connect(self._preparationFinished)
Expand Down
8 changes: 4 additions & 4 deletions python/console/console_editor.py
Expand Up @@ -432,7 +432,7 @@ def codepad(self):
getCmd = []
for strLine in listText:
getCmd.append(strLine)
pasteText = u"\n".join(getCmd)
pasteText = "\n".join(getCmd)
url = 'http://codepad.org'
values = {'lang': 'Python',
'code': pasteText,
Expand Down Expand Up @@ -591,7 +591,7 @@ def runScriptCode(self):
tmpFile = self.createTempFile()
filename = tmpFile

self.parent.pc.shell.runCommand(u"exec(open(u'{0}'.encode('{1}')).read())"
self.parent.pc.shell.runCommand("exec(open('{0}'.encode('{1}')).read())"
.format(filename.replace("\\", "/"), sys.getfilesystemencoding()))

def runSelectedCode(self): # spellok
Expand Down Expand Up @@ -626,9 +626,9 @@ def syntaxCheck(self, filename=None, fromContextMenu=True):
if not filename:
filename = self.parent.tw.currentWidget().path
# source = open(filename, 'r').read() + '\n'
if isinstance(source, type(u"")):
if isinstance(source, type("")):
source = source.encode('utf-8')
if isinstance(filename, type(u"")):
if isinstance(filename, type("")):
filename = filename.encode('utf-8')
if filename:
compile(source, filename, 'exec')
Expand Down
2 changes: 0 additions & 2 deletions python/console/console_output.py
Expand Up @@ -18,8 +18,6 @@
***************************************************************************/
Some portions of code were taken from https://code.google.com/p/pydee/
"""
from builtins import range
from builtins import object

from qgis.PyQt.QtCore import Qt, QCoreApplication
from qgis.PyQt.QtGui import QColor, QFont, QKeySequence, QFontDatabase
Expand Down
6 changes: 2 additions & 4 deletions python/console/console_sci.py
Expand Up @@ -18,8 +18,6 @@
***************************************************************************/
Some portions of code were taken from https://code.google.com/p/pydee/
"""
from builtins import bytes
from builtins import range

from qgis.PyQt.QtCore import Qt, QByteArray, QCoreApplication, QFile, QSize
from qgis.PyQt.QtWidgets import QDialog, QMenu, QShortcut, QApplication
Expand Down Expand Up @@ -600,7 +598,7 @@ def runCommand(self, cmd):
more = False
else:
self.buffer.append(cmd)
src = u"\n".join(self.buffer)
src = "\n".join(self.buffer)
more = self.runsource(src)
if not more:
self.buffer = []
Expand All @@ -627,7 +625,7 @@ def runsource(self, source, filename='<input>', symbol='single'):
hook = sys.excepthook
try:
def excepthook(etype, value, tb):
self.write(u"".join(traceback.format_exception(etype, value, tb)))
self.write("".join(traceback.format_exception(etype, value, tb)))

sys.excepthook = excepthook

Expand Down
6 changes: 3 additions & 3 deletions python/console/console_settings.py
Expand Up @@ -18,16 +18,16 @@
***************************************************************************/
Some portions of code were taken from https://code.google.com/p/pydee/
"""
from builtins import range

from qgis.PyQt.QtCore import QCoreApplication, QSize, Qt
from qgis.PyQt.QtWidgets import QDialog, QFileDialog, QMessageBox, QTableWidgetItem
from qgis.PyQt.QtGui import QIcon, QFont, QColor, QFontDatabase
from .console_compile_apis import PrepareAPIDialog

from .ui_console_settings import Ui_SettingsDialogPythonConsole
from qgis.core import QgsSettings

from .console_compile_apis import PrepareAPIDialog
from .ui_console_settings import Ui_SettingsDialogPythonConsole


class optionsDialog(QDialog, Ui_SettingsDialogPythonConsole):

Expand Down

0 comments on commit 7823025

Please sign in to comment.