changeset 382:d36f06f07082

Minor code reorganization to previous commit * exceptions.cc (pytave::fetch_exception_message): Reorganize code to keep declaration with use, other cleanups.
author Mike Miller <mtmiller@octave.org>
date Sun, 02 Apr 2017 10:06:42 -0700
parents f777dca58361
children d18843ff4dfd
files exceptions.cc
diffstat 1 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/exceptions.cc	Sun Apr 02 05:58:35 2017 +0530
+++ b/exceptions.cc	Sun Apr 02 10:06:42 2017 -0700
@@ -50,18 +50,17 @@
   std::string fetch_exception_message (void)
   {
     PyObject *ptype, *pvalue, *ptraceback;
-    PyObject *formatted_list, *pargs;
-
     PyErr_Fetch (&ptype, &pvalue, &ptraceback);
     PyErr_NormalizeException (&ptype, &pvalue, &ptraceback);
-    std::string message;
 
-    pargs = PyTuple_New (2);
-    PyTuple_SetItem (pargs, 0, ptype);
-    PyTuple_SetItem (pargs, 1, pvalue);
-    formatted_list = py_call_function \
-      ("traceback.format_exception_only", pargs);
-    Py_DECREF (pargs);
+    PyObject *args = PyTuple_New (2);
+    PyTuple_SetItem (args, 0, ptype);
+    PyTuple_SetItem (args, 1, pvalue);
+    PyObject *formatted_list = py_call_function
+                               ("traceback.format_exception_only", args);
+    Py_DECREF (args);
+
+    std::string message;
 
     if (formatted_list && PyList_Check (formatted_list))
       {
@@ -75,8 +74,9 @@
       {
         PyErr_Restore (ptype, pvalue, ptraceback);
         PyErr_Print ();
-        message = std::string ("exceptions.cc (pytave::fetch_exception_message): Cannot call 'format_exceptions_only' for the traceback");
+        message = "exceptions.cc (pytave::fetch_exception_message): cannot call 'format_exceptions_only' for the traceback";
       }
+
     return message;
   }
 }