Skip to content

Commit ec1ae96

Browse files
committed
Merge pull request #10 from tonyroberts/travis-ci
fix all unit tests and add python 2.6 build to travis
2 parents 706e590 + fd309f5 commit ec1ae96

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
language: python
22
python:
3+
- 2.6
34
- 2.7
45
before_install:
56
- sudo apt-get install software-properties-common

pythonnet/setupmono.py

+21-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from distutils.command.build_ext import build_ext
77
from distutils.sysconfig import get_config_vars
88
from platform import architecture
9-
from subprocess import check_output, check_call
9+
from subprocess import Popen, CalledProcessError, PIPE, check_call
1010
import shutil
1111
import sys
1212
import os
@@ -77,10 +77,10 @@ def build_extension(self, ext):
7777

7878

7979
def _build_monoclr(self, ext):
80-
mono_libs = check_output("pkg-config --libs mono-2", shell=True)
81-
mono_cflags = check_output("pkg-config --cflags mono-2", shell=True)
82-
glib_libs = check_output("pkg-config --libs glib-2.0", shell=True)
83-
glib_cflags = check_output("pkg-config --cflags glib-2.0", shell=True)
80+
mono_libs = _check_output("pkg-config --libs mono-2", shell=True)
81+
mono_cflags = _check_output("pkg-config --cflags mono-2", shell=True)
82+
glib_libs = _check_output("pkg-config --libs glib-2.0", shell=True)
83+
glib_cflags = _check_output("pkg-config --cflags glib-2.0", shell=True)
8484
cflags = mono_cflags.strip() + " " + glib_cflags.strip()
8585
libs = mono_libs.strip() + " " + glib_libs.strip()
8686

@@ -129,6 +129,22 @@ def _build_monoclr(self, ext):
129129
debug=self.debug)
130130

131131

132+
def _check_output(*popenargs, **kwargs):
133+
"""subprocess.check_output from python 2.7.
134+
Added here to support building for earlier versions
135+
of Python.
136+
"""
137+
process = Popen(stdout=PIPE, *popenargs, **kwargs)
138+
output, unused_err = process.communicate()
139+
retcode = process.poll()
140+
if retcode:
141+
cmd = kwargs.get("args")
142+
if cmd is None:
143+
cmd = popenargs[0]
144+
raise CalledProcessError(retcode, cmd, output=output)
145+
return output
146+
147+
132148
if __name__ == "__main__":
133149
setup(name="pythonnet",
134150
ext_modules=[

pythonnet/src/runtime/converter.cs

+8
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,14 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result,
540540
if (Exceptions.ErrorOccurred()) {
541541
goto overflow;
542542
}
543+
544+
IntPtr check = Runtime.PyLong_FromUnsignedLong(ui);
545+
int err = Runtime.PyObject_Compare(check, op);
546+
Runtime.Decref(check);
547+
if (0 != err || Exceptions.ErrorOccurred()) {
548+
goto overflow;
549+
}
550+
543551
result = ui;
544552
return true;
545553

pythonnet/src/tests/runtests.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,13 @@ def main(verbosity=1):
6262
module = __import__(name)
6363
suite.addTests((module.test_suite(),))
6464

65-
unittest.TextTestRunner(verbosity=verbosity).run(suite)
65+
result = unittest.TextTestRunner(verbosity=verbosity).run(suite)
66+
if not result.wasSuccessful():
67+
raise Exception("Tests failed")
6668

6769
if __name__ == '__main__':
6870
main(1)
6971
if '--pause' in sys.argv:
7072
print "Press enter to continue"
7173
raw_input()
74+

0 commit comments

Comments
 (0)