Browse Source

[master] Fix Python API compatibility issue with CPython < 3.3.0

The 'p' format for booleans is not available before Python 3.3 API. So
we use the previously used fallback in these cases ('i' for C int).
Mukund Sivaraman 12 years ago
parent
commit
ed780cbba4
1 changed files with 7 additions and 0 deletions
  1. 7 0
      src/lib/python/isc/datasrc/configurableclientlist_python.cc

+ 7 - 0
src/lib/python/isc/datasrc/configurableclientlist_python.cc

@@ -165,8 +165,15 @@ ConfigurableClientList_getCachedZoneWriter(PyObject* po_self, PyObject* args) {
         PyObject* name_obj;
         int catch_load_error;
         const char* datasrc_name_p = "";
+#if (PY_VERSION_HEX >= 0x030300f0)
+        // The 'p' specifier for predicate (boolean) is available from
+        // Python 3.3 (final) only.
         if (PyArg_ParseTuple(args, "O!p|s", &isc::dns::python::name_type,
                              &name_obj, &catch_load_error, &datasrc_name_p)) {
+#else
+        if (PyArg_ParseTuple(args, "O!i|s", &isc::dns::python::name_type,
+                             &name_obj, &catch_load_error, &datasrc_name_p)) {
+#endif
             const isc::dns::Name&
                 name(isc::dns::python::PyName_ToName(name_obj));
             const std::string datasrc_name(datasrc_name_p);