+2017-01-10  Tom Tromey  <tom@tromey.com>
+
+       * python/py-cmd.c (cmdpy_destroyer)
+       (cmdpy_completer_handle_brkchars, cmdpy_completer): Use
+       gdbpy_enter.
+
 2017-01-10  Tom Tromey  <tom@tromey.com>
 
        * python/py-breakpoint.c (gdbpy_breakpoint_cond_says_stop): Use
 
 cmdpy_destroyer (struct cmd_list_element *self, void *context)
 {
   cmdpy_object *cmd;
-  struct cleanup *cleanup;
 
-  cleanup = ensure_python_env (get_current_arch (), current_language);
+  gdbpy_enter enter_py (get_current_arch (), current_language);
 
   /* Release our hold on the command object.  */
   cmd = (cmdpy_object *) context;
   xfree ((char *) self->name);
   xfree ((char *) self->doc);
   xfree ((char *) self->prefixname);
-
-  do_cleanups (cleanup);
 }
 
 /* Called by gdb to invoke the command.  */
                                 const char *text, const char *word)
 {
   PyObject *resultobj = NULL;
-  struct cleanup *cleanup;
 
-  cleanup = ensure_python_env (get_current_arch (), current_language);
+  gdbpy_enter enter_py (get_current_arch (), current_language);
 
   /* Calling our helper to obtain the PyObject of the Python
      function.  */
  done:
 
   Py_XDECREF (resultobj);
-  do_cleanups (cleanup);
 }
 
 /* Called by gdb for command completion.  */
 {
   PyObject *resultobj = NULL;
   VEC (char_ptr) *result = NULL;
-  struct cleanup *cleanup;
 
-  cleanup = ensure_python_env (get_current_arch (), current_language);
+  gdbpy_enter enter_py (get_current_arch (), current_language);
 
   /* Calling our helper to obtain the PyObject of the Python
      function.  */
  done:
 
   Py_XDECREF (resultobj);
-  do_cleanups (cleanup);
 
   return result;
 }