read them if they returned filter object requires us to do so.  */
   py_inf_frame = PyObject_CallMethod (filter, "inferior_frame", NULL);
   if (py_inf_frame == NULL)
-    goto error;
+    {
+      do_cleanups (cleanup_stack);
+      return EXT_LANG_BT_ERROR;
+    }
 
   frame = frame_object_to_frame_info (py_inf_frame);;
 
   Py_DECREF (py_inf_frame);
 
   if (frame == NULL)
-    goto error;
+    {
+      do_cleanups (cleanup_stack);
+      return EXT_LANG_BT_ERROR;
+    }
 
   TRY_CATCH (except, RETURN_MASK_ALL)
     {
   if (except.reason < 0)
     {
       gdbpy_convert_exception (except);
-      goto error;
+      do_cleanups (cleanup_stack);
+      return EXT_LANG_BT_ERROR;
     }
 
   /* stack-list-variables.  */
     {
       if (py_mi_print_variables (filter, out, &opts,
                                 args_type, frame) == EXT_LANG_BT_ERROR)
-       goto error;
+       {
+         do_cleanups (cleanup_stack);
+         return EXT_LANG_BT_ERROR;
+       }
       do_cleanups (cleanup_stack);
       return EXT_LANG_BT_COMPLETED;
     }
          if (except.reason < 0)
            {
              gdbpy_convert_exception (except);
-             goto error;
+             do_cleanups (cleanup_stack);
+             return EXT_LANG_BT_ERROR;
            }
        }
 
          PyObject *paddr = PyObject_CallMethod (filter, "address", NULL);
 
          if (paddr == NULL)
-           goto error;
+           {
+             do_cleanups (cleanup_stack);
+             return EXT_LANG_BT_ERROR;
+           }
 
          if (paddr != Py_None)
            {
       if (except.reason < 0)
        {
          gdbpy_convert_exception (except);
-         goto error;
+         do_cleanups (cleanup_stack);
+         return EXT_LANG_BT_ERROR;
        }
     }
 
          if (except.reason < 0)
            {
              gdbpy_convert_exception (except);
-             goto error;
+             do_cleanups (cleanup_stack);
+             return EXT_LANG_BT_ERROR;
            }
        }
 
          const char *function = NULL;
 
          if (py_func == NULL)
-           goto error;
+           {
+             do_cleanups (cleanup_stack);
+             return EXT_LANG_BT_ERROR;
+           }
 
          if (gdbpy_is_string (py_func))
            {
              if (function == NULL)
                {
                  Py_DECREF (py_func);
-                 goto error;
+                 do_cleanups (cleanup_stack);
+                 return EXT_LANG_BT_ERROR;
                }
              make_cleanup (xfree, function_to_free);
            }
              struct bound_minimal_symbol msymbol;
 
              if (PyErr_Occurred ())
-               goto error;
+               {
+                 do_cleanups (cleanup_stack);
+                 return EXT_LANG_BT_ERROR;
+               }
 
              msymbol = lookup_minimal_symbol_by_pc (addr);
              if (msymbol.minsym != NULL)
                               _("FrameDecorator.function: expecting a " \
                                 "String, integer or None."));
              Py_DECREF (py_func);
-             goto error;
+             do_cleanups (cleanup_stack);
+             return EXT_LANG_BT_ERROR;
            }
 
          TRY_CATCH (except, RETURN_MASK_ALL)
            {
              Py_DECREF (py_func);
              gdbpy_convert_exception (except);
-             goto error;
+             do_cleanups (cleanup_stack);
+             return EXT_LANG_BT_ERROR;
            }
          Py_DECREF (py_func);
        }
   if (print_args)
     {
       if (py_print_args (filter, out, args_type, frame) == EXT_LANG_BT_ERROR)
-       goto error;
+       {
+         do_cleanups (cleanup_stack);
+         return EXT_LANG_BT_ERROR;
+       }
     }
 
   /* File name/source/line number information.  */
       if (except.reason < 0)
        {
          gdbpy_convert_exception (except);
-         goto error;
+         do_cleanups (cleanup_stack);
+         return EXT_LANG_BT_ERROR;
        }
 
       if (PyObject_HasAttrString (filter, "filename"))
          PyObject *py_fn = PyObject_CallMethod (filter, "filename", NULL);
 
          if (py_fn == NULL)
-           goto error;
+           {
+             do_cleanups (cleanup_stack);
+             return EXT_LANG_BT_ERROR;
+           }
 
          if (py_fn != Py_None)
            {
              if (filename == NULL)
                {
                  Py_DECREF (py_fn);
-                 goto error;
+                 do_cleanups (cleanup_stack);
+                 return EXT_LANG_BT_ERROR;
                }
 
              make_cleanup (xfree, filename);
                {
                  Py_DECREF (py_fn);
                  gdbpy_convert_exception (except);
-                 goto error;
+                 do_cleanups (cleanup_stack);
+                 return EXT_LANG_BT_ERROR;
                }
            }
          Py_DECREF (py_fn);
          int line;
 
          if (py_line == NULL)
-           goto error;
+           {
+             do_cleanups (cleanup_stack);
+             return EXT_LANG_BT_ERROR;
+           }
 
          if (py_line != Py_None)
            {
                {
                  Py_DECREF (py_line);
                  gdbpy_convert_exception (except);
-                 goto error;
+                 do_cleanups (cleanup_stack);
+                 return EXT_LANG_BT_ERROR;
                }
            }
          Py_DECREF (py_line);
       if (except.reason < 0)
        {
          gdbpy_convert_exception (except);
-         goto error;
+         do_cleanups (cleanup_stack);
+         return EXT_LANG_BT_ERROR;
        }
     }
 
     {
       if (py_print_locals (filter, out, args_type, indent,
                           frame) == EXT_LANG_BT_ERROR)
-       goto error;
+       {
+         do_cleanups (cleanup_stack);
+         return EXT_LANG_BT_ERROR;
+       }
     }
 
   {
     /* Finally recursively print elided frames, if any.  */
     elided = get_py_iter_from_func (filter, "elided");
     if (elided == NULL)
-      goto error;
+      {
+       do_cleanups (cleanup_stack);
+       return EXT_LANG_BT_ERROR;
+      }
 
     make_cleanup_py_decref (elided);
     if (elided != Py_None)
            if (success == EXT_LANG_BT_ERROR)
              {
                Py_DECREF (item);
-               goto error;
+               do_cleanups (cleanup_stack);
+               return EXT_LANG_BT_ERROR;
              }
 
            Py_DECREF (item);
          }
        if (item == NULL && PyErr_Occurred ())
-         goto error;
+         {
+           do_cleanups (cleanup_stack);
+           return EXT_LANG_BT_ERROR;
+         }
       }
     }
 
 
   do_cleanups (cleanup_stack);
   return EXT_LANG_BT_COMPLETED;
-
- error:
-  do_cleanups (cleanup_stack);
-  return EXT_LANG_BT_ERROR;
 }
 
 /* Helper function to initiate frame filter invocation at starting