Automatic date update in version.in
[platform/upstream/binutils.git] / gdb / python / py-utils.c
index e78dee0..deca3e8 100644 (file)
@@ -1,6 +1,6 @@
 /* General utility routines for GDB/Python.
 
-   Copyright (C) 2008-2013 Free Software Foundation, Inc.
+   Copyright (C) 2008-2014 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -31,12 +31,7 @@ py_decref (void *p)
 {
   PyObject *py = p;
 
-  /* Note that we need the extra braces in this 'if' to avoid a
-     warning from gcc.  */
-  if (py)
-    {
-      Py_DECREF (py);
-    }
+  Py_DECREF (py);
 }
 
 /* Return a new cleanup which will decrement the Python object's
@@ -76,7 +71,7 @@ make_cleanup_py_xdecref (PyObject *py)
 
    As an added bonus, the functions accepts a unicode string and returns it
    right away, so callers don't need to check which kind of string they've
-   got.  In Python 3, all strings are Unicode so this case is always the 
+   got.  In Python 3, all strings are Unicode so this case is always the
    one that applies.
 
    If the given object is not one of the mentioned string types, NULL is
@@ -221,7 +216,7 @@ python_string_to_host_string (PyObject *obj)
   if (str == NULL)
     return NULL;
 
-  result = unicode_to_encoded_string (str, host_charset ()); 
+  result = unicode_to_encoded_string (str, host_charset ());
   Py_DECREF (str);
   return result;
 }
@@ -293,7 +288,7 @@ gdbpy_exception_to_string (PyObject *ptype, PyObject *pvalue)
 }
 
 /* Convert a GDB exception to the appropriate Python exception.
-   
+
    This sets the Python error indicator.  */
 
 void
@@ -441,11 +436,9 @@ gdb_pymodule_addobject (PyObject *module, const char *name, PyObject *object)
   int result;
 
   Py_INCREF (object);
-  result = PyModule_AddObject (module, name, object);
+  /* Python 2.4 did not have a 'const' here.  */
+  result = PyModule_AddObject (module, (char *) name, object);
   if (result < 0)
-    {
-      /* Python 2.6 did not wrap Py_DECREF in do { } while (0);.  */
-      Py_DECREF (object);
-    }
+    Py_DECREF (object);
   return result;
 }