aboutsummaryrefslogtreecommitdiffstats
path: root/vt100module.c
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-09-17 17:29:01 -0400
committerJesse Luehrs <doy@tozt.net>2014-09-17 17:29:01 -0400
commitd8d27e297d6891a44afb70fa624eab862c8145c4 (patch)
treeab079ac15e719063210b7a843a165bc4edbdee1d /vt100module.c
parent2f34d1359b65fd49424476d503120e2614c5f77c (diff)
downloadlibvt100-python-d8d27e297d6891a44afb70fa624eab862c8145c4.tar.gz
libvt100-python-d8d27e297d6891a44afb70fa624eab862c8145c4.zip
support python 2
Diffstat (limited to 'vt100module.c')
-rw-r--r--vt100module.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/vt100module.c b/vt100module.c
index f564b87..ed0d808 100644
--- a/vt100module.c
+++ b/vt100module.c
@@ -76,7 +76,11 @@ static PyObject *py_vt100_get_string_formatted(PyObject *self, PyObject *args)
vt100_screen_get_string_formatted(vt, &start, &end, &outstr, &outlen);
+#if PY_MAJOR_VERSION == 3
return Py_BuildValue("y#", outstr, outlen);
+#else
+ return Py_BuildValue("s#", outstr, outlen);
+#endif
}
static PyObject *py_vt100_get_string_plaintext(PyObject *self, PyObject *args)
@@ -92,7 +96,11 @@ static PyObject *py_vt100_get_string_plaintext(PyObject *self, PyObject *args)
vt100_screen_get_string_plaintext(vt, &start, &end, &outstr, &outlen);
+#if PY_MAJOR_VERSION == 3
return Py_BuildValue("y#", outstr, outlen);
+#else
+ return Py_BuildValue("s#", outstr, outlen);
+#endif
}
static PyObject *py_vt100_delete(PyObject *self, PyObject *args)
@@ -118,6 +126,7 @@ static PyMethodDef vt100_methods[] = {
{ NULL, NULL, 0, NULL }
};
+#if PY_MAJOR_VERSION == 3
static struct PyModuleDef vt100module = {
PyModuleDef_HEAD_INIT,
"vt100_raw",
@@ -130,3 +139,9 @@ PyMODINIT_FUNC PyInit_vt100_raw()
{
return PyModule_Create(&vt100module);
}
+#else
+PyMODINIT_FUNC initvt100_raw()
+{
+ (void) Py_InitModule("vt100_raw", vt100_methods);
+}
+#endif