Skip to content

Commit fbc2a4e

Browse files
committed
Fix locale problems in PyQgsAppStartup test
1 parent 0cc7ae0 commit fbc2a4e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/python/qgspythonutilsimpl.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ bool QgsPythonUtilsImpl::checkSystemImports()
8282
// locally installed plugins have priority over the system plugins
8383
// use os.path.expanduser to support usernames with special characters (see #2512)
8484
QStringList pluginpaths;
85-
Q_FOREACH ( QString p, extraPluginsPaths() )
85+
Q_FOREACH ( const QString& p, extraPluginsPaths() )
8686
{
8787
if ( !QDir( p ).exists() )
8888
{
@@ -97,7 +97,11 @@ bool QgsPythonUtilsImpl::checkSystemImports()
9797
// we store here paths in unicode strings
9898
// the str constant will contain utf8 code (through runString)
9999
// so we call '...'.decode('utf-8') to make a unicode string
100+
#if (PY_VERSION_HEX < 0x03000000)
100101
pluginpaths << '"' + p + "\".decode('utf-8')";
102+
#else
103+
pluginpaths << '"' + p + '"';
104+
#endif
101105
}
102106
pluginpaths << homePluginsPath();
103107
pluginpaths << '"' + pluginsPath() + '"';

tests/src/python/test_qgsappstartup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import subprocess
2424
import tempfile
2525
import errno
26+
import locale
2627

2728
from qgis.testing import unittest
2829
from utilities import unitTestDataPath
@@ -118,6 +119,8 @@ def testPluginPath(self):
118119
for t in ['test_plugins', 'test plugins', u'test_pluginsé€']:
119120

120121
# get a unicode test dir
122+
if sys.version_info.major == 2:
123+
t = t.encode(locale.getpreferredencoding())
121124
testDir = os.path.join(self.TMP_DIR, t)
122125

123126
# copy from testdata
@@ -137,7 +140,7 @@ def testPluginPath(self):
137140
testFile="plugin_started.txt",
138141
timeOut=270,
139142
loadPlugins=True,
140-
env={'QGIS_PLUGINPATH': testDir.encode('ascii', 'ignore')})
143+
env={'QGIS_PLUGINPATH': testDir})
141144

142145
def testPyQgisStartupEnvVar(self):
143146
# verify PYQGIS_STARTUP env variable file is run by embedded interpreter

0 commit comments

Comments
 (0)