diff --git a/.travis.yml b/.travis.yml index a9d5ace13..63d673adf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: python python: + - 2.6 - 2.7 before_install: - sudo apt-get install software-properties-common diff --git a/pythonnet/setupmono.py b/pythonnet/setupmono.py index bf13fb5a9..7a0b02901 100644 --- a/pythonnet/setupmono.py +++ b/pythonnet/setupmono.py @@ -6,7 +6,7 @@ from distutils.command.build_ext import build_ext from distutils.sysconfig import get_config_vars from platform import architecture -from subprocess import check_output, check_call +from subprocess import Popen, CalledProcessError, PIPE, check_call import shutil import sys import os @@ -77,10 +77,10 @@ def build_extension(self, ext): def _build_monoclr(self, ext): - mono_libs = check_output("pkg-config --libs mono-2", shell=True) - mono_cflags = check_output("pkg-config --cflags mono-2", shell=True) - glib_libs = check_output("pkg-config --libs glib-2.0", shell=True) - glib_cflags = check_output("pkg-config --cflags glib-2.0", shell=True) + mono_libs = _check_output("pkg-config --libs mono-2", shell=True) + mono_cflags = _check_output("pkg-config --cflags mono-2", shell=True) + glib_libs = _check_output("pkg-config --libs glib-2.0", shell=True) + glib_cflags = _check_output("pkg-config --cflags glib-2.0", shell=True) cflags = mono_cflags.strip() + " " + glib_cflags.strip() libs = mono_libs.strip() + " " + glib_libs.strip() @@ -129,6 +129,22 @@ def _build_monoclr(self, ext): debug=self.debug) +def _check_output(*popenargs, **kwargs): + """subprocess.check_output from python 2.7. + Added here to support building for earlier versions + of Python. + """ + process = Popen(stdout=PIPE, *popenargs, **kwargs) + output, unused_err = process.communicate() + retcode = process.poll() + if retcode: + cmd = kwargs.get("args") + if cmd is None: + cmd = popenargs[0] + raise CalledProcessError(retcode, cmd, output=output) + return output + + if __name__ == "__main__": setup(name="pythonnet", ext_modules=[ diff --git a/pythonnet/src/runtime/converter.cs b/pythonnet/src/runtime/converter.cs index af7acd972..650a6178a 100644 --- a/pythonnet/src/runtime/converter.cs +++ b/pythonnet/src/runtime/converter.cs @@ -540,6 +540,14 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result, if (Exceptions.ErrorOccurred()) { goto overflow; } + + IntPtr check = Runtime.PyLong_FromUnsignedLong(ui); + int err = Runtime.PyObject_Compare(check, op); + Runtime.Decref(check); + if (0 != err || Exceptions.ErrorOccurred()) { + goto overflow; + } + result = ui; return true; diff --git a/pythonnet/src/tests/runtests.py b/pythonnet/src/tests/runtests.py index 3ce023fca..452b701f8 100755 --- a/pythonnet/src/tests/runtests.py +++ b/pythonnet/src/tests/runtests.py @@ -62,10 +62,13 @@ def main(verbosity=1): module = __import__(name) suite.addTests((module.test_suite(),)) - unittest.TextTestRunner(verbosity=verbosity).run(suite) + result = unittest.TextTestRunner(verbosity=verbosity).run(suite) + if not result.wasSuccessful(): + raise Exception("Tests failed") if __name__ == '__main__': main(1) if '--pause' in sys.argv: print "Press enter to continue" raw_input() +