Created
April 6, 2015 12:55
-
-
Save jbergstroem/1e2dbe22d530322617d7 to your computer and use it in GitHub Desktop.
libucl py2.7 support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/python/src/uclmodule.c b/python/src/uclmodule.c | |
index fb1dbda..23499f7 100644 | |
--- a/python/src/uclmodule.c | |
+++ b/python/src/uclmodule.c | |
@@ -136,6 +136,7 @@ static PyMethodDef uclMethods[] = { | |
{NULL, NULL, 0, NULL} | |
}; | |
+#if PY_MAJOR_VERSION >= 3 | |
static struct PyModuleDef uclmodule = { | |
PyModuleDef_HEAD_INIT, | |
"ucl", | |
@@ -146,5 +147,10 @@ static struct PyModuleDef uclmodule = { | |
PyMODINIT_FUNC | |
PyInit_ucl(void) { | |
- return PyModule_Create(&uclmodule); | |
+ return PyModule_Create(&uclmodule); | |
} | |
+#else | |
+void initucl(void) { | |
+ Py_InitModule("ucl", uclMethods); | |
+} | |
+#endif | |
diff --git a/python/test_uclmodule.py b/python/test_uclmodule.py | |
index 97565bb..de295dc 100755 | |
--- a/python/test_uclmodule.py | |
+++ b/python/test_uclmodule.py | |
@@ -2,6 +2,11 @@ | |
import json | |
import unittest | |
import ucl | |
+import sys | |
+ | |
+if sys.version_info[:2] == (2, 7): | |
+ unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp | |
+ | |
class TestUcl(unittest.TestCase): | |
def test_no_args(self): |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment