Skip to content

Commit 02c5637

Browse files
committedMar 22, 2016
py2/py3 compat patches
1 parent 83d729c commit 02c5637

File tree

7 files changed

+41
-25
lines changed

7 files changed

+41
-25
lines changed
 

‎.travis.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,19 @@ matrix:
4949
git:
5050
depth: 30
5151

52-
# notifications:
53-
# irc: "chat.freenode.net#qgis-test"
54-
# on_failure: change
55-
# on_success: change
56-
# skip_join: true
57-
#
58-
# notifications:
59-
# webhooks:
60-
# urls:
61-
# - https://webhooks.gitter.im/e/467e3aff72e344d1dae3
62-
# on_success: change # options: [always|never|change] default: always
63-
# on_failure: always # options: [always|never|change] default: always
64-
# on_start: never # default: never
52+
notifications:
53+
irc: "chat.freenode.net#qgis-test"
54+
on_failure: change
55+
on_success: change
56+
skip_join: true
57+
58+
notifications:
59+
webhooks:
60+
urls:
61+
- https://webhooks.gitter.im/e/467e3aff72e344d1dae3
62+
on_success: change # options: [always|never|change] default: always
63+
on_failure: always # options: [always|never|change] default: always
64+
on_start: never # default: never
6565

6666
before_install:
6767
- ./ci/travis/${TRAVIS_OS_NAME}/before_install.sh

‎ci/travis/linux/qt4/before_install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ sudo apt-get install --force-yes --no-install-recommends --no-install-suggests \
6666
postgresql-9.1-postgis-2.1/precise # from ubuntugis-unstable, not pgdg
6767

6868
sudo -H pip install autopep8 # TODO when switching to trusty or above: replace python-pip with python-autopep8
69-
sudo -H pip install nose2 pyyaml mock
69+
sudo -H pip install nose2 pyyaml mock future
7070

7171
#update clang
7272
sudo apt-get install --force-yes llvm-3.8 llvm-3.8-dev clang-3.8 libstdc++-4.9-dev

‎ci/travis/linux/qt5/blacklist.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ PyQgsDelimitedTextProvider
2424
PyQgsDistanceArea
2525
PyQgsDocCoverage
2626
PyQgsEditWidgets
27-
PyQgsExpression
2827
PyQgsFeature
2928
PyQgsFeatureIterator
3029
PyQgsField

‎ci/travis/osx/before_install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ mkdir -p ${HOME}/Library/Python/2.7/lib/python/site-packages
1818
echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> ${HOME}/Library/Python/2.7/lib/python/site-packages/homebrew.pth
1919

2020
# Needed for Processing
21-
pip install psycopg2 numpy nose2 pyyaml mock
21+
pip install psycopg2 numpy nose2 pyyaml mock future

‎python/utils.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
* *
1717
***************************************************************************
1818
"""
19+
from __future__ import absolute_import
20+
from future import standard_library
21+
standard_library.install_aliases()
22+
from builtins import str
1923

2024
__author__ = 'Martin Dobias'
2125
__date__ = 'November 2009'
@@ -37,7 +41,10 @@
3741
import traceback
3842
import glob
3943
import os.path
40-
import ConfigParser
44+
try:
45+
import configparser
46+
except ImportError:
47+
import ConfigParser as configparser
4148
import warnings
4249
import codecs
4350
import time
@@ -237,7 +244,7 @@ def findPlugins(path):
237244
if not os.path.exists(metadataFile):
238245
continue
239246

240-
cp = ConfigParser.ConfigParser()
247+
cp = configparser.ConfigParser()
241248

242249
try:
243250
f = codecs.open(metadataFile, "r", "utf8")
@@ -476,7 +483,7 @@ def reloadProjectMacros():
476483
mod = imp.new_module("proj_macros_mod")
477484

478485
# set the module code and store it sys.modules
479-
exec(unicode(code), mod.__dict__)
486+
exec(str(code), mod.__dict__)
480487
sys.modules["proj_macros_mod"] = mod
481488

482489
# load new macros
@@ -574,9 +581,15 @@ def startServerPlugin(packageName):
574581
#######################
575582
# IMPORT wrapper
576583

577-
import __builtin__
584+
try:
585+
import builtins
586+
587+
_builtin_import = builtins.__import__
588+
except AttributeError:
589+
import __builtin__
590+
591+
_builtin_import = __builtin__.__import__
578592

579-
_builtin_import = __builtin__.__import__
580593
_plugin_modules = {}
581594

582595

@@ -603,5 +616,7 @@ def _import(name, globals={}, locals={}, fromlist=[], level=None):
603616

604617
return mod
605618

606-
607-
__builtin__.__import__ = _import
619+
try:
620+
builtins.__import__ = _import
621+
except AttributeError:
622+
__builtin__.__import__ = _import

‎src/python/qgspythonutilsimpl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <QMessageBox>
3333
#include <QStringList>
3434
#include <QDir>
35+
#include <QDebug>
3536

3637
#if (PY_VERSION_HEX < 0x03000000)
3738
#define PYOBJ2QSTRING(obj) PyString_AsString( obj )
@@ -335,6 +336,7 @@ bool QgsPythonUtilsImpl::runString( const QString& command, QString msgOnError,
335336
+ QObject::tr( "Python path:" ) + "<br>" + path;
336337
str.replace( '\n', "<br>" ).replace( " ", "&nbsp; " );
337338

339+
qDebug() << str;
338340
QgsMessageOutput* msg = QgsMessageOutput::createMessageOutput();
339341
msg->setTitle( QObject::tr( "Python error" ) );
340342
msg->setMessage( str, QgsMessageOutput::MessageHtml );

‎tests/src/python/test_qgsexpression.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def testBlockComment(self):
150150
comment
151151
**/""": 'test*/'
152152
}
153-
for e, exp_res in expressions.iteritems():
153+
for e, exp_res in expressions.items():
154154
exp = QgsExpression(e)
155155
result = exp.evaluate()
156156
self.assertEqual(exp_res, result)
@@ -164,7 +164,7 @@ def testComment(self):
164164
"'test--'": 'test--',
165165
"'--test'": '--test',
166166
}
167-
for e, exp_res in expressions.iteritems():
167+
for e, exp_res in expressions.items():
168168
exp = QgsExpression(e)
169169
result = exp.evaluate()
170170
self.assertEqual(exp_res, result)

0 commit comments

Comments
 (0)
Please sign in to comment.