diff options
author | Jesse Luehrs <doy@tozt.net> | 2014-09-17 17:29:01 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2014-09-17 17:29:01 -0400 |
commit | d8d27e297d6891a44afb70fa624eab862c8145c4 (patch) | |
tree | ab079ac15e719063210b7a843a165bc4edbdee1d | |
parent | 2f34d1359b65fd49424476d503120e2614c5f77c (diff) | |
download | libvt100-python-d8d27e297d6891a44afb70fa624eab862c8145c4.tar.gz libvt100-python-d8d27e297d6891a44afb70fa624eab862c8145c4.zip |
support python 2
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | vt100module.c | 15 |
2 files changed, 16 insertions, 0 deletions
@@ -2,3 +2,4 @@ __pycache__ /build/ /MANIFEST /dist/ +*.pyc 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 |