[Jppy-commit] [SCM] jppy - Python bindings and API for jpilot databases and a GTK2 GUI branch, master, updated. releases/0.0.48-218-gb61103b

Nick Piper nick-git@nickpiper.co.uk
Tue Feb 24 23:00:20 GMT 2009


The following commit has been merged in the master branch:
commit b61103b4448ec332049ab22a401b0380ce586b02
Author: Nick Piper <nick-git@nickpiper.co.uk>
Date:   Tue Feb 24 23:00:17 2009 +0000

    Some Python 2.4 compatability

diff --git a/jppy/conduits/announce_events.py b/jppy/conduits/announce_events.py
index 87ffd98..4a48ceb 100644
--- a/jppy/conduits/announce_events.py
+++ b/jppy/conduits/announce_events.py
@@ -4,7 +4,10 @@ from jppy.core import Component, implements
 from jppy.config import ListOption, Option
 
 import smtplib
-from email.mime.text import MIMEText
+try:
+    from email.mime.text import MIMEText
+except ImportError, e:
+    from email import MIMEText
 
 class AnnounceEvents(Conduit):
     """
diff --git a/python_module_src/python_compatibility.h b/python_module_src/python_compatibility.h
index 1ad0639..dee81ea 100644
--- a/python_module_src/python_compatibility.h
+++ b/python_module_src/python_compatibility.h
@@ -1,9 +1,22 @@
+#ifndef PYTHON_COMPAT_H
+#define PYTHON_COMPAT_H
+
 /* some things for handling issues with backwards compatibility */
 
 /* Back-compatibility with Python 2.4 */
-#if (PY_VERSION_HEX < 0x02050000)
+/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */
+#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
 typedef int Py_ssize_t;
+# define PY_SSIZE_T_MAX INT_MAX
+# define PY_SSIZE_T_MIN INT_MIN
+#endif
+
+/* Should try avoid these I think, by rewriting our functions to take
+   PyObject* rather than our own types */
+#if PY_VERSION_HEX < 0x02050000
 typedef inquiry lenfunc;
 typedef intargfunc ssizeargfunc;
 typedef intobjargproc ssizeobjargproc;
 #endif
+
+#endif
diff --git a/python_module_src/pytype_basics.h b/python_module_src/pytype_basics.h
index 5a43dd2..2ea835b 100644
--- a/python_module_src/pytype_basics.h
+++ b/python_module_src/pytype_basics.h
@@ -3,6 +3,7 @@
 #include <Python.h>
 #include <mxDateTime.h>
 #include "../jpilot_src/libplugin.h"
+#include "python_compatibility.h"
 #include <pi-buffer.h>
 #include <vobject.h>
 

-- 
jppy - Python bindings and API for jpilot databases and a GTK2 GUI



More information about the Jppy-commit mailing list