Index: src/sas/sasgui/perspectives/fitting/fitting.py
===================================================================
--- src/sas/sasgui/perspectives/fitting/fitting.py	(revision a5cffe570a689752aa7b74ce8a71d2b1704e624f)
+++ src/sas/sasgui/perspectives/fitting/fitting.py	(revision a5cffe570a689752aa7b74ce8a71d2b1704e624f)
@@ -147,5 +147,5 @@
         Given an ID create a fitproblem container
         """
-        if page_id in self.page_finder.iterkeys():
+        if page_id in self.page_finder:
             del self.page_finder[page_id]
 
@@ -356,5 +356,5 @@
             # categories, the updated plugin may be in either the form factor
             # or the structure factor combo boxes
-            for uid, page in self.fit_panel.opened_pages.iteritems():
+            for uid, page in self.fit_panel.opened_pages.items():
                 pbox = getattr(page, "formfactorbox", None)
                 sbox = getattr(page, "structurebox", None)
@@ -417,6 +417,6 @@
                 self.fit_panel.SetSelection(current_page_index)
 
-        except Exception:
-            logger.error("update_custom_combo: %s", sys.exc_value)
+        except Exception as exc:
+            logger.error("update_custom_combo: %s", exc)
 
     def set_edit_menu(self, owner):
@@ -642,6 +642,6 @@
                             data.list_group_id.append(group_id)
                         self.add_fit_page(data=[data])
-            except:
-                msg = "Fitting set_data: " + str(sys.exc_value)
+            except Exception as exc:
+                msg = "Fitting set_data: " + str(exc)
                 wx.PostEvent(self.parent, StatusEvent(status=msg, info="error"))
 
@@ -654,8 +654,8 @@
                 _, theory_state = item
                 self.fit_panel.set_model_state(theory_state)
-            except Exception:
+            except Exception as exc:
                 msg = "Fitting: cannot deal with the theory received"
                 evt = StatusEvent(status=msg, info="error")
-                logger.error("set_theory " + msg + "\n" + str(sys.exc_value))
+                logger.error("set_theory " + msg + "\n" + str(exc))
                 wx.PostEvent(self.parent, evt)
 
@@ -778,5 +778,5 @@
         # Note: this is used to set the data weights for the fit based on
         # the weight selection in the GUI.
-        if uid in self.page_finder.keys():
+        if uid in self.page_finder:
             self.page_finder[uid].set_weight(flag=flag, is2d=is2d)
 
@@ -791,5 +791,5 @@
         :param qmax: maximum  value of the fit range
         """
-        if uid in self.page_finder.keys():
+        if uid in self.page_finder:
             self.page_finder[uid].set_range(qmin=qmin, qmax=qmax, fid=fid)
 
@@ -802,5 +802,5 @@
         :param uid: the id related to a page containing fitting information
         """
-        if uid in self.page_finder.keys():
+        if uid in self.page_finder:
             self.page_finder[uid].schedule_tofit(value)
 
@@ -821,5 +821,5 @@
         """
         sim_page_id = self.sim_page.uid
-        for uid, value in self.page_finder.iteritems():
+        for uid, value in self.page_finder.items():
             if uid != sim_page_id and uid != self.batch_page.uid:
                 model_list = value.get_model()
@@ -886,5 +886,5 @@
         Stop the fit
         """
-        if uid in self.fit_thread_list.keys():
+        if uid in self.fit_thread_list:
             calc_fit = self.fit_thread_list[uid]
             if calc_fit is not  None and calc_fit.isrunning():
@@ -898,7 +898,7 @@
         batch_flag = self.batch_page is not None and uid == self.batch_page.uid
         if sim_flag or batch_flag:
-            for uid, value in self.page_finder.iteritems():
+            for uid, value in self.page_finder.items():
                 if value.get_scheduled() == 1:
-                    if uid in self.fit_panel.opened_pages.keys():
+                    if uid in self.fit_panel.opened_pages:
                         panel = self.fit_panel.opened_pages[uid]
                         panel._on_fit_complete()
@@ -917,5 +917,5 @@
         :param draw: Determine if the theory needs to be plot
         """
-        if uid not in self.page_finder.keys():
+        if uid not in self.page_finder:
             return
         self.page_finder[uid].enable_smearing(flag=enable_smearer)
@@ -928,5 +928,5 @@
                 msg += "Got data = %s .\n" % str(data)
                 return
-                #raise ValueError, msg
+                #raise ValueError(msg)
             model = self.page_finder[uid].get_model(fid=fid)
             if model is None:
@@ -1030,5 +1030,5 @@
         list_page_id = []
         fit_id = 0
-        for page_id, page_info in self.page_finder.iteritems():
+        for page_id, page_info in self.page_finder.items():
             # For simulfit (uid give with None), do for-loop
             # if uid is specified (singlefit), do it only on the page.
@@ -1057,6 +1057,5 @@
 
                     pars = [str(element[1]) for element in page.param_toFit]
-                    fitproblem_list = page_info.values()
-                    for fitproblem in  fitproblem_list:
+                    for fitproblem in page_info.values():
                         if sim_fitter is None:
                             fitter = Fit()
@@ -1077,7 +1076,7 @@
                 wx.PostEvent(self.parent, evt)
                 return True
-            except:
+            except Exception as exc:
                 raise
-                msg = "Fitting error: %s" % str(sys.exc_value)
+                msg = "Fitting error: %s" % exc
                 evt = StatusEvent(status=msg, info="error", type="stop")
                 wx.PostEvent(self.parent, evt)
@@ -1136,5 +1135,5 @@
         :param fid: the id of the fitproblem(data, model, range,etc)
         """
-        if uid not in self.page_finder.keys():
+        if uid not in self.page_finder:
             return
         fitproblemList = self.page_finder[uid].get_fit_problem(fid)
@@ -1181,6 +1180,6 @@
                 evt = StatusEvent(status=msg, info="warning")
                 wx.PostEvent(self.parent, evt)
-        except Exception:
-            msg = "Creating Fit page: %s" % sys.exc_value
+        except Exception as exc:
+            msg = "Creating Fit page: %s" % exc
             wx.PostEvent(self.parent, StatusEvent(status=msg, info="error"))
 
@@ -1262,9 +1261,9 @@
         # case that uid is not specified
         if uid is None:
-            for page_id in self.page_finder.keys():
+            for page_id in self.page_finder:
                 self.page_finder[page_id].schedule_tofit(value)
         # when uid is given
         else:
-            if uid in self.page_finder.keys():
+            if uid in self.page_finder:
                 self.page_finder[uid].schedule_tofit(value)
 
@@ -1300,5 +1299,5 @@
         panel = self.plot_panel
         if panel is None:
-            raise ValueError, "Fitting:_onSelect: NonType panel"
+            raise ValueError("Fitting:_onSelect: NonType panel")
         Plugin.on_perspective(self, event=event)
         self.select_data(panel)
@@ -1333,5 +1332,5 @@
         """
         uid = page_id[0]
-        if uid in self.fit_thread_list.keys():
+        if uid in self.fit_thread_list:
             del self.fit_thread_list[uid]
 
@@ -1359,16 +1358,16 @@
                 #get all fittable parameters of the current model
                 for param in  model.getParamList():
-                    if param  not in batch_outputs.keys():
+                    if param  not in batch_outputs:
                         batch_outputs[param] = []
                 for param in model.getDispParamList():
                     if not model.is_fittable(param) and \
-                        param in batch_outputs.keys():
+                        param in batch_outputs:
                         del batch_outputs[param]
                 # Add fitted parameters and their error
                 for param in res.param_list:
-                    if param not in batch_outputs.keys():
+                    if param not in batch_outputs:
                         batch_outputs[param] = []
                     err_param = "error on %s" % str(param)
-                    if err_param not in batch_inputs.keys():
+                    if err_param not in batch_inputs:
                         batch_inputs[err_param] = []
         msg = ""
@@ -1524,5 +1523,5 @@
         model = fitproblem.get_model()
         #fill batch result information
-        if "Data" not in batch_outputs.keys():
+        if "Data" not in batch_outputs:
             batch_outputs["Data"] = []
         cell = BatchCell()
@@ -1553,6 +1552,6 @@
         cell.object = [data, theory_data]
         batch_outputs["Data"].append(cell)
-        for key, value in data.meta_data.iteritems():
-            if key not in batch_inputs.keys():
+        for key, value in data.meta_data.items():
+            if key not in batch_inputs:
                 batch_inputs[key] = []
             #if key.lower().strip() != "loader":
@@ -1560,5 +1559,5 @@
         param = "temperature"
         if hasattr(data.sample, param):
-            if param not in  batch_inputs.keys():
+            if param not in  batch_inputs:
                 batch_inputs[param] = []
             batch_inputs[param].append(data.sample.temperature)
@@ -1631,7 +1630,6 @@
                     wx.PostEvent(self.parent, evt)
 
-        except Exception:
-            msg = ("Fit completed but the following error occurred: %s"
-                   % sys.exc_value)
+        except Exception as exc:
+            msg = "Fit completed but the following error occurred: %s" % exc
             #msg = "\n".join((traceback.format_exc(), msg))
             evt = StatusEvent(status=msg, info="warning", type="stop")
@@ -1721,5 +1719,5 @@
         if model is None:
             return
-        if uid not in self.page_finder.keys():
+        if uid not in self.page_finder:
             return
         # save the name containing the data name with the appropriate model
@@ -2078,7 +2076,7 @@
                                   source=source)
             self.calc_1D.queue()
-        except:
+        except Exception as exc:
             msg = " Error occurred when drawing %s Model 1D: " % model.name
-            msg += " %s" % sys.exc_value
+            msg += " %s" % exc
             wx.PostEvent(self.parent, StatusEvent(status=msg))
 
