[pytango] 183/483: avoid warning on python 2.6

Sandor Bodo-Merle sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:38 UTC 2017


This is an automated email from the git hooks/post-receive script.

sbodomerle-guest pushed a commit to annotated tag bliss_8.10
in repository pytango.

commit 3e1e08d0b3f58e0a2be75ca3a879b67931d0ef4a
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date:   Wed Jan 16 11:58:09 2013 +0000

    avoid warning on python 2.6
    
    git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@21903 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
 src/boost/cpp/pyutils.cpp | 75 +++++++++++++++++++++++++++++++++++++++++++++++
 src/boost/cpp/pyutils.h   | 73 ++-------------------------------------------
 2 files changed, 77 insertions(+), 71 deletions(-)

diff --git a/src/boost/cpp/pyutils.cpp b/src/boost/cpp/pyutils.cpp
index fdfa556..ee1012e 100644
--- a/src/boost/cpp/pyutils.cpp
+++ b/src/boost/cpp/pyutils.cpp
@@ -120,3 +120,78 @@ void is_method_defined(PyObject *obj, const std::string &method_name,
     is_method = (1 == PyCallable_Check(meth));
     Py_DECREF(meth);
 }
+
+#ifdef PYCAPSULE_OLD
+
+static int
+PyCapsule_SetName(PyObject *capsule, const char *unused)
+{
+    unused = unused;
+    PyErr_SetString(PyExc_NotImplementedError,
+        "can't use PyCapsule_SetName with CObjects");
+    return 1;
+}
+
+static void *
+PyCapsule_Import(const char *name, int no_block)
+{
+    PyObject *object = NULL;
+    void *return_value = NULL;
+    char *trace;
+    size_t name_length = (strlen(name) + 1) * sizeof(char);
+    char *name_dup = (char *)PyMem_MALLOC(name_length);
+
+    if (!name_dup) {
+        return NULL;
+    }
+
+    memcpy(name_dup, name, name_length);
+
+    trace = name_dup;
+    while (trace) {
+        char *dot = strchr(trace, '.');
+        if (dot) {
+            *dot++ = '\0';
+        }
+
+        if (object == NULL) {
+            if (no_block) {
+                object = PyImport_ImportModuleNoBlock(trace);
+            } else {
+                object = PyImport_ImportModule(trace);
+                if (!object) {
+                    PyErr_Format(PyExc_ImportError,
+                        "PyCapsule_Import could not "
+                        "import module \"%s\"", trace);
+                }
+            }
+        } else {
+            PyObject *object2 = PyObject_GetAttrString(object, trace);
+            Py_DECREF(object);
+            object = object2;
+        }
+        if (!object) {
+            goto EXIT;
+        }
+
+        trace = dot;
+    }
+
+    if (PyCObject_Check(object)) {
+        PyCObject *cobject = (PyCObject *)object;
+        return_value = cobject->cobject;
+    } else {
+        PyErr_Format(PyExc_AttributeError,
+            "PyCapsule_Import \"%s\" is not valid",
+            name);
+    }
+
+EXIT:
+    Py_XDECREF(object);
+    if (name_dup) {
+        PyMem_FREE(name_dup);
+    }
+    return return_value;
+}
+
+#endif
diff --git a/src/boost/cpp/pyutils.h b/src/boost/cpp/pyutils.h
index 686dddb..6f7a979 100644
--- a/src/boost/cpp/pyutils.h
+++ b/src/boost/cpp/pyutils.h
@@ -153,16 +153,7 @@ inline PyObject *PyImport_ImportModule_(const std::string &name)
  */
 #define PyCapsule_GetName(capsule) NULL
 
-static int
-PyCapsule_SetName(PyObject *capsule, const char *unused)
-{
-    unused = unused;
-    PyErr_SetString(PyExc_NotImplementedError,
-        "can't use PyCapsule_SetName with CObjects");
-    return 1;
-}
-
-
+static int PyCapsule_SetName(PyObject *capsule, const char *unused);
 
 #define PyCapsule_GetContext(capsule) \
     __PyCapsule_GetField(capsule, descr)
@@ -171,67 +162,7 @@ PyCapsule_SetName(PyObject *capsule, const char *unused)
     __PyCapsule_SetField(capsule, descr, context)
 
 
-static void *
-PyCapsule_Import(const char *name, int no_block)
-{
-    PyObject *object = NULL;
-    void *return_value = NULL;
-    char *trace;
-    size_t name_length = (strlen(name) + 1) * sizeof(char);
-    char *name_dup = (char *)PyMem_MALLOC(name_length);
-
-    if (!name_dup) {
-        return NULL;
-    }
-
-    memcpy(name_dup, name, name_length);
-
-    trace = name_dup;
-    while (trace) {
-        char *dot = strchr(trace, '.');
-        if (dot) {
-            *dot++ = '\0';
-        }
-
-        if (object == NULL) {
-            if (no_block) {
-                object = PyImport_ImportModuleNoBlock(trace);
-            } else {
-                object = PyImport_ImportModule(trace);
-                if (!object) {
-                    PyErr_Format(PyExc_ImportError,
-                        "PyCapsule_Import could not "
-                        "import module \"%s\"", trace);
-                }
-            }
-        } else {
-            PyObject *object2 = PyObject_GetAttrString(object, trace);
-            Py_DECREF(object);
-            object = object2;
-        }
-        if (!object) {
-            goto EXIT;
-        }
-
-        trace = dot;
-    }
-
-    if (PyCObject_Check(object)) {
-        PyCObject *cobject = (PyCObject *)object;
-        return_value = cobject->cobject;
-    } else {
-        PyErr_Format(PyExc_AttributeError,
-            "PyCapsule_Import \"%s\" is not valid",
-            name);
-    }
-
-EXIT:
-    Py_XDECREF(object);
-    if (name_dup) {
-        PyMem_FREE(name_dup);
-    }
-    return return_value;
-}
+static void * PyCapsule_Import(const char *name, int no_block);
 
 #endif /* #if PY_VERSION_HEX < 0x02070000 */
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pytango.git



More information about the debian-science-commits mailing list