Selaa lähdekoodia

Python3 support: exception objects require 'as' keyword (compliant with Python >= 2.6) (trac https://trac.osgeo.org/grass/ticket/2288)

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@60217 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler 11 vuotta sitten
vanhempi
commit
7df99e8331
73 muutettua tiedostoa jossa 156 lisäystä ja 156 poistoa
  1. 1 1
      doc/gui/wxpython/example/frame.py
  2. 3 3
      gui/wxpython/animation/controller.py
  3. 1 1
      gui/wxpython/animation/data.py
  4. 3 3
      gui/wxpython/animation/dialogs.py
  5. 1 1
      gui/wxpython/animation/temporal_manager.py
  6. 4 4
      gui/wxpython/core/gcmd.py
  7. 4 4
      gui/wxpython/core/gconsole.py
  8. 4 4
      gui/wxpython/core/globalvar.py
  9. 2 2
      gui/wxpython/core/render.py
  10. 4 4
      gui/wxpython/core/settings.py
  11. 1 1
      gui/wxpython/core/toolboxes.py
  12. 7 7
      gui/wxpython/core/utils.py
  13. 6 6
      gui/wxpython/dbmgr/base.py
  14. 2 2
      gui/wxpython/gcp/manager.py
  15. 5 5
      gui/wxpython/gis_set.py
  16. 2 2
      gui/wxpython/gmodeler/frame.py
  17. 1 1
      gui/wxpython/gmodeler/model.py
  18. 4 4
      gui/wxpython/gui_core/forms.py
  19. 2 2
      gui/wxpython/gui_core/goutput.py
  20. 3 3
      gui/wxpython/gui_core/gselect.py
  21. 1 1
      gui/wxpython/gui_core/prompt.py
  22. 1 1
      gui/wxpython/gui_core/simplelmgr.py
  23. 1 1
      gui/wxpython/iclass/frame.py
  24. 1 1
      gui/wxpython/iclass/statistics.py
  25. 1 1
      gui/wxpython/icons/icon.py
  26. 1 1
      gui/wxpython/iscatt/core_c.py
  27. 2 2
      gui/wxpython/lmgr/frame.py
  28. 1 1
      gui/wxpython/location_wizard/dialogs.py
  29. 2 2
      gui/wxpython/location_wizard/wizard.py
  30. 2 2
      gui/wxpython/mapdisp/main.py
  31. 5 5
      gui/wxpython/mapdisp/statusbar.py
  32. 1 1
      gui/wxpython/mapwin/analysis.py
  33. 4 4
      gui/wxpython/mapwin/buffered.py
  34. 1 1
      gui/wxpython/modules/colorrules.py
  35. 1 1
      gui/wxpython/modules/extensions.py
  36. 1 1
      gui/wxpython/nviz/main.py
  37. 2 2
      gui/wxpython/nviz/mapwindow.py
  38. 1 1
      gui/wxpython/nviz/tools.py
  39. 1 1
      gui/wxpython/psmap/dialogs.py
  40. 2 2
      gui/wxpython/psmap/frame.py
  41. 6 6
      gui/wxpython/psmap/instructions.py
  42. 1 1
      gui/wxpython/timeline/g.gui.timeline.py
  43. 1 1
      gui/wxpython/tools/update_menudata.py
  44. 1 1
      gui/wxpython/vdigit/main.py
  45. 2 2
      gui/wxpython/wxgui.py
  46. 1 1
      gui/wxpython/wxplot/base.py
  47. 2 2
      gui/wxpython/wxplot/histogram.py
  48. 2 2
      gui/wxpython/wxplot/profile.py
  49. 2 2
      gui/wxpython/wxplot/scatter.py
  50. 4 4
      lib/init/grass.py
  51. 1 1
      lib/python/ctypes/ctypesgencore/libraryloader.py
  52. 3 3
      lib/python/ctypes/ctypesgencore/parser/lex.py
  53. 2 2
      lib/python/ctypes/ctypesgencore/parser/pplexer.py
  54. 4 4
      lib/python/ctypes/ctypesgencore/parser/yacc.py
  55. 1 1
      lib/python/ctypes/ctypesgencore/processor/operations.py
  56. 1 1
      lib/python/ctypes/loader.py
  57. 1 1
      lib/python/pydispatch/robust.py
  58. 1 1
      lib/python/pydispatch/saferef.py
  59. 2 2
      lib/python/script/core.py
  60. 2 2
      lib/python/script/task.py
  61. 1 1
      lib/python/temporal/gui_support.py
  62. 2 2
      man/build_html.py
  63. 2 2
      man/build_rest.py
  64. 2 2
      scripts/d.redraw/d.redraw.py
  65. 1 1
      scripts/g.extension.all/g.extension.all.py
  66. 4 4
      scripts/g.extension/g.extension.py
  67. 2 2
      scripts/r.in.wms/wms_base.py
  68. 3 3
      scripts/r.in.wms/wms_drv.py
  69. 1 1
      scripts/r.pack/r.pack.py
  70. 1 1
      scripts/v.krige/v.krige.py
  71. 1 1
      temporal/t.register/t.register.py
  72. 2 2
      tools/g.html2man/g.html2man.py
  73. 2 2
      tools/reindent.py

+ 1 - 1
doc/gui/wxpython/example/frame.py

@@ -46,7 +46,7 @@ from dialogs import ExampleMapDialog
 #     from grass.lib.raster import *
 #     from grass.lib.raster import *
 #     haveExample = True
 #     haveExample = True
 #     errMsg = ''
 #     errMsg = ''
-# except ImportError, e:
+# except ImportError as e:
 #     haveExample = False
 #     haveExample = False
 #     errMsg = _("Loading raster lib failed.\n%s") % e
 #     errMsg = _("Loading raster lib failed.\n%s") % e
 
 

+ 3 - 3
gui/wxpython/animation/controller.py

@@ -242,7 +242,7 @@ class AnimationController(wx.EvtHandler):
             return
             return
         try:
         try:
             temporalMode, tempManager = self.EvaluateInput(self.animationData + [animData])
             temporalMode, tempManager = self.EvaluateInput(self.animationData + [animData])
-        except GException, e:
+        except GException as e:
             GError(parent=self.frame, message=e.value, showTraceback=False)
             GError(parent=self.frame, message=e.value, showTraceback=False)
             return
             return
         # if ok, set temporal mode
         # if ok, set temporal mode
@@ -273,7 +273,7 @@ class AnimationController(wx.EvtHandler):
             return
             return
         try:
         try:
             temporalMode, tempManager = self.EvaluateInput(animationData)
             temporalMode, tempManager = self.EvaluateInput(animationData)
-        except GException, e:
+        except GException as e:
             GError(parent=self.frame, message=e.value, showTraceback=False)
             GError(parent=self.frame, message=e.value, showTraceback=False)
             return
             return
         self.animationData = animationData
         self.animationData = animationData
@@ -561,7 +561,7 @@ class AnimationController(wx.EvtHandler):
                          duration=self.timeTick / float(1000),
                          duration=self.timeTick / float(1000),
                          encoding=exportInfo['encoding'],
                          encoding=exportInfo['encoding'],
                          inputOptions=exportInfo['options'])
                          inputOptions=exportInfo['options'])
-        except Exception, e:
+        except Exception as e:
             del busy
             del busy
             GError(parent=self.frame, message=str(e))
             GError(parent=self.frame, message=str(e))
             return
             return

+ 1 - 1
gui/wxpython/animation/data.py

@@ -277,7 +277,7 @@ class AnimLayer(Layer):
                 try:
                 try:
                     name = validateTimeseriesName(name, self._mapType)
                     name = validateTimeseriesName(name, self._mapType)
                     self._maps = getRegisteredMaps(name, self._mapType)
                     self._maps = getRegisteredMaps(name, self._mapType)
-                except (GException, gcore.ScriptError), e:
+                except (GException, gcore.ScriptError) as e:
                     raise ValueError(str(e))
                     raise ValueError(str(e))
             else:
             else:
                 self._maps = validateMapNames(name.split(','), self._mapType)
                 self._maps = validateMapNames(name.split(','), self._mapType)

+ 3 - 3
gui/wxpython/animation/dialogs.py

@@ -727,7 +727,7 @@ class EditDialog(wx.Dialog):
             return
             return
         try:
         try:
             temporalMode, tempManager = self.eval(self.animationData)
             temporalMode, tempManager = self.eval(self.animationData)
-        except GException, e:
+        except GException as e:
             GError(parent=self, message=e.value, showTraceback=False)
             GError(parent=self, message=e.value, showTraceback=False)
             return
             return
         self.result = (self.animationData, temporalMode, tempManager)
         self.result = (self.animationData, temporalMode, tempManager)
@@ -1392,7 +1392,7 @@ class AddTemporalLayerDialog(wx.Dialog):
                     if maps:
                     if maps:
                         mapName, mapLayer = getNameAndLayer(maps[0])
                         mapName, mapLayer = getNameAndLayer(maps[0])
                         cmd.append('map={name}'.format(name=mapName))
                         cmd.append('map={name}'.format(name=mapName))
-                except gcore.ScriptError, e:
+                except gcore.ScriptError as e:
                     GError(parent=self, message=str(e), showTraceback=False)
                     GError(parent=self, message=str(e), showTraceback=False)
                     return None
                     return None
         return cmd
         return cmd
@@ -1444,7 +1444,7 @@ class AddTemporalLayerDialog(wx.Dialog):
                 self.layer.name = self._name
                 self.layer.name = self._name
                 self.layer.cmd = self._cmd
                 self.layer.cmd = self._cmd
                 event.Skip()
                 event.Skip()
-            except (GException, gcore.ScriptError), e:
+            except (GException, gcore.ScriptError) as e:
                 GError(parent=self, message=str(e))
                 GError(parent=self, message=str(e))
 
 
     def GetLayer(self):
     def GetLayer(self):

+ 1 - 1
gui/wxpython/animation/temporal_manager.py

@@ -354,7 +354,7 @@ def test():
     try:
     try:
         warn = temp.EvaluateInputData()
         warn = temp.EvaluateInputData()
         print warn
         print warn
-    except GException, e:
+    except GException as e:
         print e
         print e
         return
         return
 
 

+ 4 - 4
gui/wxpython/core/gcmd.py

@@ -213,7 +213,7 @@ class Popen(subprocess.Popen):
                 (errCode, written) = WriteFile(x, input)
                 (errCode, written) = WriteFile(x, input)
             except ValueError:
             except ValueError:
                 return self._close('stdin')
                 return self._close('stdin')
-            except (subprocess.pywintypes.error, Exception), why:
+            except (subprocess.pywintypes.error, Exception) as why:
                 if why[0] in (109, errno.ESHUTDOWN):
                 if why[0] in (109, errno.ESHUTDOWN):
                     return self._close('stdin')
                     return self._close('stdin')
                 raise
                 raise
@@ -234,7 +234,7 @@ class Popen(subprocess.Popen):
                     (errCode, read) = ReadFile(x, nAvail, None)
                     (errCode, read) = ReadFile(x, nAvail, None)
             except ValueError:
             except ValueError:
                 return self._close(which)
                 return self._close(which)
-            except (subprocess.pywintypes.error, Exception), why:
+            except (subprocess.pywintypes.error, Exception) as why:
                 if why[0] in (109, errno.ESHUTDOWN):
                 if why[0] in (109, errno.ESHUTDOWN):
                     return self._close(which)
                     return self._close(which)
                 raise
                 raise
@@ -253,7 +253,7 @@ class Popen(subprocess.Popen):
 
 
             try:
             try:
                 written = os.write(self.stdin.fileno(), input)
                 written = os.write(self.stdin.fileno(), input)
-            except OSError, why:
+            except OSError as why:
                 if why[0] == errno.EPIPE: #broken pipe
                 if why[0] == errno.EPIPE: #broken pipe
                     return self._close('stdin')
                     return self._close('stdin')
                 raise
                 raise
@@ -556,7 +556,7 @@ class CommandThread(Thread):
                                 shell = sys.platform == "win32",
                                 shell = sys.platform == "win32",
                                 env = self.env)
                                 env = self.env)
             
             
-        except OSError, e:
+        except OSError as e:
             self.error = str(e)
             self.error = str(e)
             print >> sys.stderr, e
             print >> sys.stderr, e
             return 1
             return 1

+ 4 - 4
gui/wxpython/core/gconsole.py

@@ -466,7 +466,7 @@ class GConsole(wx.EvtHandler):
                 # other GRASS commands (r|v|g|...)
                 # other GRASS commands (r|v|g|...)
                 try:
                 try:
                     task = GUI(show=None).ParseCommand(command)
                     task = GUI(show=None).ParseCommand(command)
-                except GException, e:
+                except GException as e:
                     GError(parent=self._guiparent,
                     GError(parent=self._guiparent,
                            message=unicode(e),
                            message=unicode(e),
                            showTraceback=False)
                            showTraceback=False)
@@ -494,7 +494,7 @@ class GConsole(wx.EvtHandler):
                     # no arguments given
                     # no arguments given
                     try:
                     try:
                         GUI(parent=self._guiparent, giface=self._giface).ParseCommand(command)
                         GUI(parent=self._guiparent, giface=self._giface).ParseCommand(command)
-                    except GException, e:
+                    except GException as e:
                         print >> sys.stderr, e
                         print >> sys.stderr, e
                     return
                     return
 
 
@@ -643,7 +643,7 @@ class GConsole(wx.EvtHandler):
         # find which maps were created
         # find which maps were created
         try:
         try:
             task = GUI(show=None).ParseCommand(event.cmd)
             task = GUI(show=None).ParseCommand(event.cmd)
-        except GException, e:
+        except GException as e:
             print >> sys.stderr, e
             print >> sys.stderr, e
             task = None
             task = None
             return
             return
@@ -678,7 +678,7 @@ class GConsole(wx.EvtHandler):
                                     env['MAPSET'],
                                     env['MAPSET'],
                                     '.bash_history')
                                     '.bash_history')
             fileHistory = codecs.open(filePath, encoding='utf-8', mode='a')
             fileHistory = codecs.open(filePath, encoding='utf-8', mode='a')
-        except IOError, e:
+        except IOError as e:
             GError(_("Unable to write file '%(filePath)s'.\n\nDetails: %(error)s") % 
             GError(_("Unable to write file '%(filePath)s'.\n\nDetails: %(error)s") % 
                     {'filePath': filePath, 'error': e},
                     {'filePath': filePath, 'error': e},
                    parent=self._guiparent)
                    parent=self._guiparent)

+ 4 - 4
gui/wxpython/core/globalvar.py

@@ -58,7 +58,7 @@ def CheckForWx():
     try:
     try:
         try:
         try:
             import wxversion
             import wxversion
-        except ImportError, e:
+        except ImportError as e:
             raise ImportError(e)
             raise ImportError(e)
         # wxversion.select(str(minVersion[0]) + '.' + str(minVersion[1]))
         # wxversion.select(str(minVersion[0]) + '.' + str(minVersion[1]))
         wxversion.ensureMinimal(str(minVersion[0]) + '.' + str(minVersion[1]))
         wxversion.ensureMinimal(str(minVersion[0]) + '.' + str(minVersion[1]))
@@ -68,14 +68,14 @@ def CheckForWx():
         if map(int, version.split('.')) < minVersion:
         if map(int, version.split('.')) < minVersion:
             raise ValueError('Your wxPython version is %s.%s.%s.%s' % tuple(version.split('.')))
             raise ValueError('Your wxPython version is %s.%s.%s.%s' % tuple(version.split('.')))
 
 
-    except ImportError, e:
+    except ImportError as e:
         print >> sys.stderr, 'ERROR: wxGUI requires wxPython. %s' % str(e)
         print >> sys.stderr, 'ERROR: wxGUI requires wxPython. %s' % str(e)
         sys.exit(1)
         sys.exit(1)
-    except (ValueError, wxversion.VersionError), e:
+    except (ValueError, wxversion.VersionError) as e:
         print >> sys.stderr, 'ERROR: wxGUI requires wxPython >= %d.%d.%d.%d. ' % tuple(minVersion) + \
         print >> sys.stderr, 'ERROR: wxGUI requires wxPython >= %d.%d.%d.%d. ' % tuple(minVersion) + \
             '%s.' % (str(e))
             '%s.' % (str(e))
         sys.exit(1)
         sys.exit(1)
-    except locale.Error, e:
+    except locale.Error as e:
         print >> sys.stderr, "Unable to set locale:", e
         print >> sys.stderr, "Unable to set locale:", e
         os.environ['LC_ALL'] = ''
         os.environ['LC_ALL'] = ''
 
 

+ 2 - 2
gui/wxpython/core/render.py

@@ -488,7 +488,7 @@ class Map(object):
                                  "WIND")
                                  "WIND")
         try:
         try:
             windfile = open (filename, "r")
             windfile = open (filename, "r")
-        except IOError, e:
+        except IOError as e:
             sys.exit(_("Error: Unable to open '%(file)s'. Reason: %(ret)s. wxGUI exited.\n") % \
             sys.exit(_("Error: Unable to open '%(file)s'. Reason: %(ret)s. wxGUI exited.\n") % \
                          { 'file' : filename, 'ret' : e})
                          { 'file' : filename, 'ret' : e})
         
         
@@ -496,7 +496,7 @@ class Map(object):
             line = line.strip()
             line = line.strip()
             try:
             try:
                 key, value = line.split(":", 1)
                 key, value = line.split(":", 1)
-            except ValueError, e:
+            except ValueError as e:
                 sys.stderr.write(_("\nERROR: Unable to read WIND file: %s\n") % e)
                 sys.stderr.write(_("\nERROR: Unable to read WIND file: %s\n") % e)
                 return None
                 return None
             
             

+ 4 - 4
gui/wxpython/core/settings.py

@@ -44,7 +44,7 @@ class Settings:
         self.userSettings = copy.deepcopy(self.defaultSettings)
         self.userSettings = copy.deepcopy(self.defaultSettings)
         try:
         try:
             self.ReadSettingsFile()
             self.ReadSettingsFile()
-        except GException, e:
+        except GException as e:
             print >> sys.stderr, e.value
             print >> sys.stderr, e.value
         
         
         # define internal settings
         # define internal settings
@@ -971,7 +971,7 @@ class Settings:
                     value = self._parseValue(value, read = True)
                     value = self._parseValue(value, read = True)
                     self.Append(settings, group, key, subkey, value)
                     self.Append(settings, group, key, subkey, value)
                     idx += 2
                     idx += 2
-        except ValueError, e:
+        except ValueError as e:
             print >> sys.stderr, _("Error: Reading settings from file <%(file)s> failed.\n"
             print >> sys.stderr, _("Error: Reading settings from file <%(file)s> failed.\n"
                                    "\t\tDetails: %(detail)s\n"
                                    "\t\tDetails: %(detail)s\n"
                                    "\t\tLine: '%(line)s'\n") % { 'file' : filename,
                                    "\t\tLine: '%(line)s'\n") % { 'file' : filename,
@@ -1024,9 +1024,9 @@ class Settings:
                                     type(settings[group][key][subkeys[idx + 1]]) != types.DictType:
                                     type(settings[group][key][subkeys[idx + 1]]) != types.DictType:
                                 file.write('%s' % self.sep)
                                 file.write('%s' % self.sep)
                     file.write(os.linesep)
                     file.write(os.linesep)
-        except IOError, e:
+        except IOError as e:
             raise GException(e)
             raise GException(e)
-        except StandardError, e:
+        except StandardError as e:
             raise GException(_('Writing settings to file <%(file)s> failed.'
             raise GException(_('Writing settings to file <%(file)s> failed.'
                                '\n\nDetails: %(detail)s') % { 'file' : self.filePath,
                                '\n\nDetails: %(detail)s') % { 'file' : self.filePath,
                                                               'detail' : e })
                                                               'detail' : e })

+ 1 - 1
gui/wxpython/core/toolboxes.py

@@ -162,7 +162,7 @@ def _createPath(path):
     if not os.path.exists(path):
     if not os.path.exists(path):
         try:
         try:
             os.mkdir(path)
             os.mkdir(path)
-        except OSError, e:
+        except OSError as e:
             # we cannot use GError or similar because the gui doesn''t start at all
             # we cannot use GError or similar because the gui doesn''t start at all
             gcore.warning('%(reason)s\n%(detail)s' % 
             gcore.warning('%(reason)s\n%(detail)s' % 
                     ({'reason':_('Unable to create toolboxes directory.'),
                     ({'reason':_('Unable to create toolboxes directory.'),

+ 7 - 7
gui/wxpython/core/utils.py

@@ -558,7 +558,7 @@ def ReadEpsgCodes(path):
                 code, params = line.split(" ", 1)
                 code, params = line.split(" ", 1)
                 try:
                 try:
                     code = int(code.replace('<', '').replace('>', ''))
                     code = int(code.replace('<', '').replace('>', ''))
-                except ValueError, e:
+                except ValueError as e:
                     return e
                     return e
             
             
             if code is not None:
             if code is not None:
@@ -566,7 +566,7 @@ def ReadEpsgCodes(path):
                 code = None
                 code = None
         
         
         f.close()
         f.close()
-    except StandardError, e:
+    except StandardError as e:
         return e
         return e
     
     
     return epsgCodeDict
     return epsgCodeDict
@@ -622,7 +622,7 @@ def GetListOfLocations(dbase):
                     listOfLocations.append(os.path.basename(location))
                     listOfLocations.append(os.path.basename(location))
             except:
             except:
                 pass
                 pass
-    except UnicodeEncodeError, e:
+    except UnicodeEncodeError as e:
         raise e
         raise e
     
     
     ListSortLower(listOfLocations)
     ListSortLower(listOfLocations)
@@ -838,7 +838,7 @@ def GetSettingsPath():
     try:
     try:
         verFd = open(os.path.join(globalvar.ETCDIR, "VERSIONNUMBER"))
         verFd = open(os.path.join(globalvar.ETCDIR, "VERSIONNUMBER"))
         version = int(verFd.readlines()[0].split(' ')[0].split('.')[0])
         version = int(verFd.readlines()[0].split(' ')[0].split('.')[0])
-    except (IOError, ValueError, TypeError, IndexError), e:
+    except (IOError, ValueError, TypeError, IndexError) as e:
         sys.exit(_("ERROR: Unable to determine GRASS version. Details: %s") % e)
         sys.exit(_("ERROR: Unable to determine GRASS version. Details: %s") % e)
     
     
     verFd.close()
     verFd.close()
@@ -873,14 +873,14 @@ def StoreEnvVariable(key, value = None, envFile = None):
     if os.path.exists(envFile):
     if os.path.exists(envFile):
         try:
         try:
             fd = open(envFile)
             fd = open(envFile)
-        except IOError, e:
+        except IOError as e:
             sys.stderr.write(_("Unable to open file '%s'\n") % envFile)
             sys.stderr.write(_("Unable to open file '%s'\n") % envFile)
             return
             return
         for line in fd.readlines():
         for line in fd.readlines():
             line = line.rstrip(os.linesep)
             line = line.rstrip(os.linesep)
             try:
             try:
                 k, v = map(lambda x: x.strip(), line.split(' ', 1)[1].split('=', 1))
                 k, v = map(lambda x: x.strip(), line.split(' ', 1)[1].split('=', 1))
-            except StandardError, e:
+            except StandardError as e:
                 sys.stderr.write(_("%s: line skipped - unable to parse '%s'\n"
                 sys.stderr.write(_("%s: line skipped - unable to parse '%s'\n"
                                    "Reason: %s\n") % (envFile, line, e))
                                    "Reason: %s\n") % (envFile, line, e))
                 lineSkipped.append(line)
                 lineSkipped.append(line)
@@ -901,7 +901,7 @@ def StoreEnvVariable(key, value = None, envFile = None):
     # write update env file
     # write update env file
     try:
     try:
         fd = open(envFile, 'w')
         fd = open(envFile, 'w')
-    except IOError, e:
+    except IOError as e:
         sys.stderr.write(_("Unable to create file '%s'\n") % envFile)
         sys.stderr.write(_("Unable to create file '%s'\n") % envFile)
         return
         return
     if windows:
     if windows:

+ 6 - 6
gui/wxpython/dbmgr/base.py

@@ -87,7 +87,7 @@ class VirtualAttributeList(wx.ListCtrl,
         
         
         try:
         try:
             keyColumn = self.LoadData(layer)
             keyColumn = self.LoadData(layer)
-        except GException, e:
+        except GException as e:
             GError(parent = self,
             GError(parent = self,
                    message = e.value)
                    message = e.value)
             return
             return
@@ -308,7 +308,7 @@ class VirtualAttributeList(wx.ListCtrl,
             if not cat and keyId > -1 and keyId == j:
             if not cat and keyId > -1 and keyId == j:
                 try:
                 try:
                     cat = self.columns[columns[j]]['ctype'] (value)
                     cat = self.columns[columns[j]]['ctype'] (value)
-                except ValueError, e:
+                except ValueError as e:
                     cat = -1
                     cat = -1
                     GError(parent = self,
                     GError(parent = self,
                            message = _("Error loading attribute data. "
                            message = _("Error loading attribute data. "
@@ -1344,7 +1344,7 @@ class DbMgrBrowsePage(DbMgrNotebookBase):
                             updateList.append("%s=%s" % (columnName[i], values[i]))
                             updateList.append("%s=%s" % (columnName[i], values[i]))
                     else: # -> NULL
                     else: # -> NULL
                         updateList.append("%s=NULL" % (columnName[i]))
                         updateList.append("%s=NULL" % (columnName[i]))
-            except ValueError, err:
+            except ValueError as err:
                 GError(parent = self,
                 GError(parent = self,
                        message = _("Unable to update existing record.\n%s") % err,
                        message = _("Unable to update existing record.\n%s") % err,
                        showTraceback = False)
                        showTraceback = False)
@@ -1447,7 +1447,7 @@ class DbMgrBrowsePage(DbMgrNotebookBase):
                     else:
                     else:
                         valuesString += "%s," % values[i]
                         valuesString += "%s," % values[i]
                 
                 
-            except ValueError, err:
+            except ValueError as err:
                 GError(parent = self,
                 GError(parent = self,
                        message = _("Unable to insert new record.\n%s") % err,
                        message = _("Unable to insert new record.\n%s") % err,
                        showTraceback = False)
                        showTraceback = False)
@@ -1803,7 +1803,7 @@ class DbMgrBrowsePage(DbMgrNotebookBase):
                     keyColumn = listWin.LoadData(self.selLayer, where = whereCol + whereOpe + whereVal)
                     keyColumn = listWin.LoadData(self.selLayer, where = whereCol + whereOpe + whereVal)
                 else:
                 else:
                     keyColumn = listWin.LoadData(self.selLayer)
                     keyColumn = listWin.LoadData(self.selLayer)
-            except GException, e:
+            except GException as e:
                 GError(parent = self,
                 GError(parent = self,
                        message = _("Loading attribute data failed.\n\n%s") % e.value)
                        message = _("Loading attribute data failed.\n\n%s") % e.value)
                 self.FindWindowById(self.layerPage[self.selLayer]['where']).SetValue('')
                 self.FindWindowById(self.layerPage[self.selLayer]['where']).SetValue('')
@@ -1828,7 +1828,7 @@ class DbMgrBrowsePage(DbMgrNotebookBase):
                 try:
                 try:
                     keyColumn = listWin.LoadData(self.selLayer, columns = cols,
                     keyColumn = listWin.LoadData(self.selLayer, columns = cols,
                                                  where = where, sql = sql)
                                                  where = where, sql = sql)
-                except GException, e:
+                except GException as e:
                     GError(parent = self,
                     GError(parent = self,
                            message = _("Loading attribute data failed.\n\n%s") % e.value)
                            message = _("Loading attribute data failed.\n\n%s") % e.value)
                     win.SetValue("SELECT * FROM %s" % self.dbMgrData['mapDBInfo'].layers[self.selLayer]['table'])
                     win.SetValue("SELECT * FROM %s" % self.dbMgrData['mapDBInfo'].layers[self.selLayer]['table'])

+ 2 - 2
gui/wxpython/gcp/manager.py

@@ -1238,7 +1238,7 @@ class GCP(MapFrame, ColumnSorterMixin):
                 coord3 = self.list.GetItem(index, 4).GetText()
                 coord3 = self.list.GetItem(index, 4).GetText()
                 f.write(coord0 + ' ' + coord1 + '     ' + coord2 + ' ' + coord3 + '     ' + check + '\n')
                 f.write(coord0 + ' ' + coord1 + '     ' + coord2 + ' ' + coord3 + '     ' + check + '\n')
 
 
-        except IOError, err:
+        except IOError as err:
             GError(parent = self,
             GError(parent = self,
                    message="%s <%s>. %s%s" % (_("Writing POINTS file failed"),
                    message="%s <%s>. %s%s" % (_("Writing POINTS file failed"),
                                               self.file['points'], os.linesep, err))
                                               self.file['points'], os.linesep, err))
@@ -1295,7 +1295,7 @@ class GCP(MapFrame, ColumnSorterMixin):
                     self.list.CheckItem(index, check)
                     self.list.CheckItem(index, check)
                 GCPcnt += 1
                 GCPcnt += 1
 
 
-        except IOError, err:
+        except IOError as err:
             GError(parent = self,
             GError(parent = self,
                    message = "%s <%s>. %s%s" % (_("Reading POINTS file failed"),
                    message = "%s <%s>. %s%s" % (_("Reading POINTS file failed"),
                                                 self.file['points'], os.linesep, err))
                                                 self.file['points'], os.linesep, err))

+ 5 - 5
gui/wxpython/gis_set.py

@@ -406,7 +406,7 @@ class GRASSStartup(wx.Frame):
                 for line in rc.readlines():
                 for line in rc.readlines():
                     try:
                     try:
                         key, val = line.split(":", 1)
                         key, val = line.split(":", 1)
-                    except ValueError, e:
+                    except ValueError as e:
                         sys.stderr.write(_('Invalid line in GISRC file (%s):%s\n' % \
                         sys.stderr.write(_('Invalid line in GISRC file (%s):%s\n' % \
                                                (e, line)))
                                                (e, line)))
                     grassrc[key.strip()] = DecodeString(val.strip())
                     grassrc[key.strip()] = DecodeString(val.strip())
@@ -593,7 +593,7 @@ class GRASSStartup(wx.Frame):
                               os.path.join(self.gisdbase, location, newmapset))
                               os.path.join(self.gisdbase, location, newmapset))
                     self.OnSelectLocation(None)
                     self.OnSelectLocation(None)
                     self.lbmapsets.SetSelection(self.listOfMapsets.index(newmapset))
                     self.lbmapsets.SetSelection(self.listOfMapsets.index(newmapset))
-                except StandardError, e:
+                except StandardError as e:
                     wx.MessageBox(parent = self,
                     wx.MessageBox(parent = self,
                                   caption = _('Error'),
                                   caption = _('Error'),
                                   message = _('Unable to rename mapset.\n\n%s') % e,
                                   message = _('Unable to rename mapset.\n\n%s') % e,
@@ -630,7 +630,7 @@ class GRASSStartup(wx.Frame):
                     self.UpdateLocations(self.gisdbase)
                     self.UpdateLocations(self.gisdbase)
                     self.lblocations.SetSelection(self.listOfLocations.index(newlocation))
                     self.lblocations.SetSelection(self.listOfLocations.index(newlocation))
                     self.UpdateMapsets(newlocation)
                     self.UpdateMapsets(newlocation)
-                except StandardError, e:
+                except StandardError as e:
                     wx.MessageBox(parent = self,
                     wx.MessageBox(parent = self,
                                   caption = _('Error'),
                                   caption = _('Error'),
                                   message = _('Unable to rename location.\n\n%s') % e,
                                   message = _('Unable to rename location.\n\n%s') % e,
@@ -887,7 +887,7 @@ class GRASSStartup(wx.Frame):
             self.lbmapsets.SetSelection(self.listOfMapsets.index(mapset))
             self.lbmapsets.SetSelection(self.listOfMapsets.index(mapset))
             self.bstart.SetFocus()
             self.bstart.SetFocus()
             return True
             return True
-        except StandardError, e:
+        except StandardError as e:
             GError(parent = self,
             GError(parent = self,
                    message = _("Unable to create new mapset: %s") % e,
                    message = _("Unable to create new mapset: %s") % e,
                    showTraceback = False)
                    showTraceback = False)
@@ -930,7 +930,7 @@ class GRASSStartup(wx.Frame):
                 if ret == wx.ID_YES:
                 if ret == wx.ID_YES:
                     try:
                     try:
                         os.remove(lockfile)
                         os.remove(lockfile)
-                    except IOError, e:
+                    except IOError as e:
                         GError(_("Unable to remove '%(lock)s'.\n\n"
                         GError(_("Unable to remove '%(lock)s'.\n\n"
                                  "Details: %(reason)s") % { 'lock' : lockfile, 'reason' : e})
                                  "Details: %(reason)s") % { 'lock' : lockfile, 'reason' : e})
                 else:
                 else:

+ 2 - 2
gui/wxpython/gmodeler/frame.py

@@ -861,7 +861,7 @@ class ModelFrame(wx.Frame):
         """
         """
         try:
         try:
             self.model.LoadModel(filename)
             self.model.LoadModel(filename)
-        except GException, e:
+        except GException as e:
             GError(parent = self,
             GError(parent = self,
                    message = _("Reading model file <%s> failed.\n"
                    message = _("Reading model file <%s> failed.\n"
                                "Invalid file, unable to parse XML document.\n\n%s") % \
                                "Invalid file, unable to parse XML document.\n\n%s") % \
@@ -1706,7 +1706,7 @@ class PythonPanel(wx.Panel):
         try:
         try:
             fd = open(self.filename, "w")
             fd = open(self.filename, "w")
             fd.write(self.body.GetText())
             fd.write(self.body.GetText())
-        except IOError, e:
+        except IOError as e:
             GError(_("Unable to launch Python script. %s") % e,
             GError(_("Unable to launch Python script. %s") % e,
                    parent = self)
                    parent = self)
             return
             return

+ 1 - 1
gui/wxpython/gmodeler/model.py

@@ -294,7 +294,7 @@ class Model(object):
         # parse workspace file
         # parse workspace file
         try:
         try:
             gxmXml = ProcessModelFile(etree.parse(filename))
             gxmXml = ProcessModelFile(etree.parse(filename))
-        except StandardError, e:
+        except StandardError as e:
             raise GException(e)
             raise GException(e)
         
         
         if self.canvas:
         if self.canvas:

+ 4 - 4
gui/wxpython/gui_core/forms.py

@@ -697,7 +697,7 @@ class TaskFrame(wx.Frame):
                     cmd[0] = self.task.path # full path
                     cmd[0] = self.task.path # full path
                 
                 
                 ret = self._gconsole.RunCmd(cmd, onDone = self.OnDone)
                 ret = self._gconsole.RunCmd(cmd, onDone = self.OnDone)
-            except AttributeError, e:
+            except AttributeError as e:
                 print >> sys.stderr, "%s: Probably not running in wxgui.py session?" % (e)
                 print >> sys.stderr, "%s: Probably not running in wxgui.py session?" % (e)
                 print >> sys.stderr, "parent window is: %s" % (str(self.parent))
                 print >> sys.stderr, "parent window is: %s" % (str(self.parent))
         else:
         else:
@@ -1829,7 +1829,7 @@ class CmdPanel(wx.Panel):
         data = ''
         data = ''
         try:
         try:
             f = open(path, "r")
             f = open(path, "r")
-        except IOError, e:
+        except IOError as e:
             gcmd.GError(parent = self, showTraceback = False,
             gcmd.GError(parent = self, showTraceback = False,
                         message = _("Unable to load file.\n\nReason: %s") % e)
                         message = _("Unable to load file.\n\nReason: %s") % e)
             return
             return
@@ -2204,7 +2204,7 @@ class CmdPanel(wx.Panel):
         try:
         try:
             cmd = self.task.get_cmd(ignoreErrors = ignoreErrors,
             cmd = self.task.get_cmd(ignoreErrors = ignoreErrors,
                                    ignoreRequired = ignoreRequired)
                                    ignoreRequired = ignoreRequired)
-        except ValueError, err:
+        except ValueError as err:
             dlg = wx.MessageDialog(parent = self,
             dlg = wx.MessageDialog(parent = self,
                                    message = unicode(err),
                                    message = unicode(err),
                                    caption = _("Error in %s") % self.task.name,
                                    caption = _("Error in %s") % self.task.name,
@@ -2290,7 +2290,7 @@ class GUI:
             global _blackList
             global _blackList
             self.grass_task = gtask.parse_interface(gcmd.GetRealCmd(cmd[0]),
             self.grass_task = gtask.parse_interface(gcmd.GetRealCmd(cmd[0]),
                                                     blackList = _blackList)
                                                     blackList = _blackList)
-        except (grass.ScriptError, ValueError), e:
+        except (grass.ScriptError, ValueError) as e:
             raise gcmd.GException(e.value)
             raise gcmd.GException(e.value)
         
         
         # if layer parameters previously set, re-insert them into dialog
         # if layer parameters previously set, re-insert them into dialog

+ 2 - 2
gui/wxpython/gui_core/goutput.py

@@ -383,7 +383,7 @@ class GConsoleWindow(wx.SplitterWindow):
             try:
             try:
                 output = open(path, "w")
                 output = open(path, "w")
                 output.write(text)
                 output.write(text)
-            except IOError, e:
+            except IOError as e:
                 GError(_("Unable to write file '%(path)s'.\n\nDetails: %(error)s") % {'path': path, 'error': e})
                 GError(_("Unable to write file '%(path)s'.\n\nDetails: %(error)s") % {'path': path, 'error': e})
             finally:
             finally:
                 output.close()
                 output.close()
@@ -436,7 +436,7 @@ class GConsoleWindow(wx.SplitterWindow):
             output.write('\n'.join(cmds))
             output.write('\n'.join(cmds))
             if len(cmds) > 0:
             if len(cmds) > 0:
                 output.write('\n')
                 output.write('\n')
-        except IOError, e:
+        except IOError as e:
             GError(_("Unable to write file '%(filePath)s'.\n\nDetails: %(error)s") % 
             GError(_("Unable to write file '%(filePath)s'.\n\nDetails: %(error)s") % 
                     {'filePath': self.cmdFileProtocol, 'error': e})
                     {'filePath': self.cmdFileProtocol, 'error': e})
         finally:
         finally:

+ 3 - 3
gui/wxpython/gui_core/gselect.py

@@ -53,7 +53,7 @@ import grass.script as grass
 from   grass.script import task as gtask
 from   grass.script import task as gtask
 try:
 try:
     from grass.pygrass import messages
     from grass.pygrass import messages
-except ImportError, e:
+except ImportError as e:
     print >> sys.stderr, _("Unable to import pyGRASS: %s\n"
     print >> sys.stderr, _("Unable to import pyGRASS: %s\n"
                            "Some functionality will be not accessible") % e
                            "Some functionality will be not accessible") % e
 
 
@@ -511,7 +511,7 @@ class TreeCtrlComboPopup(ListCtrlComboPopup):
                     elem_list = filesdict[mapset]
                     elem_list = filesdict[mapset]
                     self._addItems(elist = elem_list, elements = elements,
                     self._addItems(elist = elem_list, elements = elements,
                                    mapset = mapset, exclude = exclude, node = node)
                                    mapset = mapset, exclude = exclude, node = node)
-            except StandardError, e:
+            except StandardError as e:
                 sys.stderr.write(_("GSelect: invalid item: %s") % e)
                 sys.stderr.write(_("GSelect: invalid item: %s") % e)
                 continue
                 continue
             
             
@@ -690,7 +690,7 @@ class TreeCtrlComboPopup(ListCtrlComboPopup):
                 import grass.temporal as tgis
                 import grass.temporal as tgis
                 try:
                 try:
                     tgis.init(True)
                     tgis.init(True)
-                except messages.FatalError, e:
+                except messages.FatalError as e:
                     sys.stderr.write("Temporal GIS error:\n%s" % e)
                     sys.stderr.write("Temporal GIS error:\n%s" % e)
                     self.tgis_error = True
                     self.tgis_error = True
         if 'mapsets' in kargs:
         if 'mapsets' in kargs:

+ 1 - 1
gui/wxpython/gui_core/prompt.py

@@ -451,7 +451,7 @@ class GPromptSTC(GPrompt, wx.stc.StyledTextCtrl):
                             if command.find(self.toComplete['cmd']) == 0:
                             if command.find(self.toComplete['cmd']) == 0:
                                 dotNumber = list(self.toComplete['cmd']).count('.') 
                                 dotNumber = list(self.toComplete['cmd']).count('.') 
                                 self.autoCompList.append(command.split('.',dotNumber)[-1])
                                 self.autoCompList.append(command.split('.',dotNumber)[-1])
-                        except UnicodeDecodeError, e: # TODO: fix it
+                        except UnicodeDecodeError as e: # TODO: fix it
                             sys.stderr.write(DecodeString(command) + ": " + unicode(e))
                             sys.stderr.write(DecodeString(command) + ": " + unicode(e))
                             
                             
             except (KeyError, TypeError):
             except (KeyError, TypeError):

+ 1 - 1
gui/wxpython/gui_core/simplelmgr.py

@@ -313,7 +313,7 @@ class SimpleLayerManager(wx.Panel):
 
 
                     layer.name = mapName
                     layer.name = mapName
                     signal.emit(index=self._layerList.GetLayerIndex(layer), layer=layer)
                     signal.emit(index=self._layerList.GetLayerIndex(layer), layer=layer)
-                except ValueError, e:
+                except ValueError as e:
                     self._layerList.RemoveLayer(layer)
                     self._layerList.RemoveLayer(layer)
                     GError(parent=self,
                     GError(parent=self,
                            message=str(e),
                            message=str(e),

+ 1 - 1
gui/wxpython/iclass/frame.py

@@ -34,7 +34,7 @@ try:
     from grass.lib.vector import *
     from grass.lib.vector import *
     haveIClass = True
     haveIClass = True
     errMsg = ''
     errMsg = ''
-except ImportError, e:
+except ImportError as e:
     haveIClass = False
     haveIClass = False
     errMsg = _("Loading imagery lib failed.\n%s") % e
     errMsg = _("Loading imagery lib failed.\n%s") % e
 
 

+ 1 - 1
gui/wxpython/iclass/statistics.py

@@ -25,7 +25,7 @@ from core.utils import _
 
 
 try:
 try:
     from grass.lib.imagery import *
     from grass.lib.imagery import *
-except ImportError, e:
+except ImportError as e:
     sys.stderr.write(_("Loading imagery lib failed"))
     sys.stderr.write(_("Loading imagery lib failed"))
 
 
 from grass.pydispatch.signal import Signal
 from grass.pydispatch.signal import Signal

+ 1 - 1
gui/wxpython/icons/icon.py

@@ -47,7 +47,7 @@ try:
             iconSet[key] = img
             iconSet[key] = img
         
         
         iconSet[key] = os.path.join(iconPath, iconSet[key])
         iconSet[key] = os.path.join(iconPath, iconSet[key])
-except StandardError, e:
+except StandardError as e:
     sys.exit(_("Unable to load icon theme. Reason: %s. Quiting wxGUI...") % e)
     sys.exit(_("Unable to load icon theme. Reason: %s. Quiting wxGUI...") % e)
     
     
 class MetaIcon:
 class MetaIcon:

+ 1 - 1
gui/wxpython/iscatt/core_c.py

@@ -19,7 +19,7 @@ from ctypes import *
 try:
 try:
     from grass.lib.imagery import *
     from grass.lib.imagery import *
     from grass.lib.gis import Cell_head, G_get_window
     from grass.lib.gis import Cell_head, G_get_window
-except ImportError, e:
+except ImportError as e:
     sys.stderr.write(_("Loading ctypes libs failed"))
     sys.stderr.write(_("Loading ctypes libs failed"))
 
 
 from core.gcmd import GException
 from core.gcmd import GException

+ 2 - 2
gui/wxpython/lmgr/frame.py

@@ -1169,7 +1169,7 @@ class GMFrame(wx.Frame):
         # parse workspace file
         # parse workspace file
         try:
         try:
             gxwXml = ProcessWorkspaceFile(etree.parse(filename))
             gxwXml = ProcessWorkspaceFile(etree.parse(filename))
-        except Exception, e:
+        except Exception as e:
             GError(parent = self,
             GError(parent = self,
                    message = _("Reading workspace file <%s> failed.\n"
                    message = _("Reading workspace file <%s> failed.\n"
                                "Invalid file, unable to parse XML document.") % filename)
                                "Invalid file, unable to parse XML document.") % filename)
@@ -1380,7 +1380,7 @@ class GMFrame(wx.Frame):
         tmpfile = tempfile.TemporaryFile(mode = 'w+b')
         tmpfile = tempfile.TemporaryFile(mode = 'w+b')
         try:
         try:
             WriteWorkspaceFile(lmgr = self, file = tmpfile)
             WriteWorkspaceFile(lmgr = self, file = tmpfile)
-        except StandardError, e:
+        except StandardError as e:
             GError(parent = self,
             GError(parent = self,
                    message = _("Writing current settings to workspace file "
                    message = _("Writing current settings to workspace file "
                                "failed."))
                                "failed."))

+ 1 - 1
gui/wxpython/location_wizard/dialogs.py

@@ -432,7 +432,7 @@ class RegionDef(BaseClass, wx.Dialog):
 
 
             self.__UpdateInfo()
             self.__UpdateInfo()
 
 
-        except ValueError, e:
+        except ValueError as e:
             if len(event.GetString()) > 0 and event.GetString() != '-':
             if len(event.GetString()) > 0 and event.GetString() != '-':
                 dlg = wx.MessageBox(parent = self,
                 dlg = wx.MessageBox(parent = self,
                                     message = _("Invalid value: %s") % e,
                                     message = _("Invalid value: %s") % e,

+ 2 - 2
gui/wxpython/location_wizard/wizard.py

@@ -533,7 +533,7 @@ class ItemList(wx.ListCtrl,
             
             
             self.SendSizeEvent()
             self.SendSizeEvent()
             
             
-        except StandardError, e:
+        except StandardError as e:
             wx.MessageBox(parent = self,
             wx.MessageBox(parent = self,
                           message = _("Unable to read list: %s") % e,
                           message = _("Unable to read list: %s") % e,
                           caption = _("Error"), style = wx.OK | wx.ICON_ERROR)
                           caption = _("Error"), style = wx.OK | wx.ICON_ERROR)
@@ -2136,7 +2136,7 @@ class LocationWizard(wx.Object):
                                       wkt = self.wktpage.wktfile,
                                       wkt = self.wktpage.wktfile,
                                       desc = self.startpage.locTitle)
                                       desc = self.startpage.locTitle)
         
         
-        except grass.ScriptError, e:
+        except grass.ScriptError as e:
             return e.value
             return e.value
         
         
         return None
         return None

+ 2 - 2
gui/wxpython/mapdisp/main.py

@@ -179,7 +179,7 @@ class DMonMap(Map):
 
 
             self.SetLayers(reorderedLayers)
             self.SetLayers(reorderedLayers)
 
 
-        except IOError, e:
+        except IOError as e:
             grass.warning(_("Unable to read cmdfile '%(cmd)s'. Details: %(det)s") % \
             grass.warning(_("Unable to read cmdfile '%(cmd)s'. Details: %(det)s") % \
                               { 'cmd' : self.cmdfile, 'det' : e })
                               { 'cmd' : self.cmdfile, 'det' : e })
             return
             return
@@ -401,7 +401,7 @@ class MapApp(wx.App):
                 self.cmdTimeStamp = currentCmdFileTime
                 self.cmdTimeStamp = currentCmdFileTime
                 self.mapFrm.GetMap().GetLayersFromCmdFile()
                 self.mapFrm.GetMap().GetLayersFromCmdFile()
                 self.timer.Start(mtime)
                 self.timer.Start(mtime)
-        except OSError, e:
+        except OSError as e:
             grass.warning("%s" % e)
             grass.warning("%s" % e)
             self.timer.Stop()
             self.timer.Stop()
 
 

+ 5 - 5
gui/wxpython/mapdisp/statusbar.py

@@ -701,7 +701,7 @@ class SbGoTo(SbItem):
                 self.SetValue("%.*f; %.*f" % \
                 self.SetValue("%.*f; %.*f" % \
                                (precision, region['center_easting'],
                                (precision, region['center_easting'],
                                 precision, region['center_northing']))
                                 precision, region['center_northing']))
-        except SbException, e:
+        except SbException as e:
             # FIXME: this may be useless since statusbar update checks user defined projection and this exception raises when user def proj does not exists
             # FIXME: this may be useless since statusbar update checks user defined projection and this exception raises when user def proj does not exists
             self.statusbar.SetStatusText(str(e), 0)
             self.statusbar.SetStatusText(str(e), 0)
 
 
@@ -750,7 +750,7 @@ class SbGoTo(SbItem):
         try:
         try:
             self.SetCenter()
             self.SetCenter()
             self.Show()
             self.Show()
-        except SbException, e:
+        except SbException as e:
             self.statusbar.SetStatusText(str(e), 0)
             self.statusbar.SetStatusText(str(e), 0)
                         
                         
         # disable long help
         # disable long help
@@ -890,10 +890,10 @@ class SbCoordinates(SbTextItem):
             else:
             else:
                 value = self._basicValue
                 value = self._basicValue
             self.SetValue(value)
             self.SetValue(value)
-        except SbException, e:
+        except SbException as e:
             self.SetValue(e.message)
             self.SetValue(e.message)
         # TODO: remove these excepts, they just hide errors, solve problems differently
         # TODO: remove these excepts, they just hide errors, solve problems differently
-        except TypeError, e:
+        except TypeError as e:
             self.SetValue("")
             self.SetValue("")
         except AttributeError:
         except AttributeError:
             self.SetValue("") # during initialization MapFrame has no MapWindow
             self.SetValue("") # during initialization MapFrame has no MapWindow
@@ -959,7 +959,7 @@ class SbRegionExtent(SbTextItem):
         try:
         try:
             regionReprojected = self.ReprojectRegionFromMap(region, projection, precision, format)
             regionReprojected = self.ReprojectRegionFromMap(region, projection, precision, format)
             self.SetValue(regionReprojected)
             self.SetValue(regionReprojected)
-        except SbException, e:
+        except SbException as e:
             self.SetValue(e.message)
             self.SetValue(e.message)
         SbTextItem.Show(self)
         SbTextItem.Show(self)
     
     

+ 1 - 1
gui/wxpython/mapwin/analysis.py

@@ -246,7 +246,7 @@ class MeasureDistanceController(AnalysisControllerBase):
                 import grass.lib.gis as gislib
                 import grass.lib.gis as gislib
                 gislib.G_begin_distance_calculations()
                 gislib.G_begin_distance_calculations()
                 self._useCtypes = True
                 self._useCtypes = True
-            except ImportError, e:
+            except ImportError as e:
                 self._giface.WriteWarning(_('Geodesic distance calculation '
                 self._giface.WriteWarning(_('Geodesic distance calculation '
                                             'is not available.\n'
                                             'is not available.\n'
                                             'Reason: %s' % e))
                                             'Reason: %s' % e))

+ 4 - 4
gui/wxpython/mapwin/buffered.py

@@ -495,7 +495,7 @@ class BufferedMapWindow(MapWindowBase, wx.Window):
                 try:
                 try:
                     gcdc = wx.GCDC(dc)
                     gcdc = wx.GCDC(dc)
                     self.pdcVector.DrawToDCClipped(gcdc, rgn)
                     self.pdcVector.DrawToDCClipped(gcdc, rgn)
-                except NotImplementedError, e:
+                except NotImplementedError as e:
                     print >> sys.stderr, e
                     print >> sys.stderr, e
                     self.pdcVector.DrawToDCClipped(dc, rgn)
                     self.pdcVector.DrawToDCClipped(dc, rgn)
             
             
@@ -510,7 +510,7 @@ class BufferedMapWindow(MapWindowBase, wx.Window):
                     try:
                     try:
                         gcdc = wx.GCDC(dc)
                         gcdc = wx.GCDC(dc)
                         self.pdcVector.DrawToDC(gcdc)
                         self.pdcVector.DrawToDC(gcdc)
-                    except NotImplementedError, e:
+                    except NotImplementedError as e:
                         print >> sys.stderr, e
                         print >> sys.stderr, e
                         self.pdcVector.DrawToDC(dc)
                         self.pdcVector.DrawToDC(dc)
                 
                 
@@ -525,7 +525,7 @@ class BufferedMapWindow(MapWindowBase, wx.Window):
         try:
         try:
             gcdc = wx.GCDC(dc)
             gcdc = wx.GCDC(dc)
             self.pdcDec.DrawToDC(gcdc)
             self.pdcDec.DrawToDC(gcdc)
-        except NotImplementedError, e:
+        except NotImplementedError as e:
             print >> sys.stderr, e
             print >> sys.stderr, e
             self.pdcDec.DrawToDC(dc)
             self.pdcDec.DrawToDC(dc)
         
         
@@ -800,7 +800,7 @@ class BufferedMapWindow(MapWindowBase, wx.Window):
             else:
             else:
                 self.mapfile = self.Map.Render(force = False)
                 self.mapfile = self.Map.Render(force = False)
             
             
-        except GException, e:
+        except GException as e:
             GError(message = e.value)
             GError(message = e.value)
             self.mapfile = None
             self.mapfile = None
         
         

+ 1 - 1
gui/wxpython/modules/colorrules.py

@@ -286,7 +286,7 @@ class RulesPanel:
                 if self.attributeType == 'color':
                 if self.attributeType == 'color':
                     try:
                     try:
                         r, g, b = map(int, self.ruleslines[item][self.attributeType].split(':'))
                         r, g, b = map(int, self.ruleslines[item][self.attributeType].split(':'))
-                    except ValueError, e:
+                    except ValueError as e:
                         message =  _("Bad color format. Use color format '0:0:0'")
                         message =  _("Bad color format. Use color format '0:0:0'")
                     self.mainPanel.FindWindowById(item + 2000).SetValue((r, g, b))
                     self.mainPanel.FindWindowById(item + 2000).SetValue((r, g, b))
                 else:
                 else:

+ 1 - 1
gui/wxpython/modules/extensions.py

@@ -191,7 +191,7 @@ class InstallExtensionWindow(wx.Frame):
         self.SetStatusText(_("Fetching list of modules from GRASS-Addons SVN (be patient)..."), 0)
         self.SetStatusText(_("Fetching list of modules from GRASS-Addons SVN (be patient)..."), 0)
         try:
         try:
             self.modelBuilder.Load(url = self.repo.GetValue().strip())
             self.modelBuilder.Load(url = self.repo.GetValue().strip())
-        except GException, e:
+        except GException as e:
             GError(unicode(e), parent = self, showTraceback = False)
             GError(unicode(e), parent = self, showTraceback = False)
         
         
         self.tree.RefreshItems()
         self.tree.RefreshItems()

+ 1 - 1
gui/wxpython/nviz/main.py

@@ -26,7 +26,7 @@ try:
     from nviz import workspace
     from nviz import workspace
     import wxnviz
     import wxnviz
     haveNviz = True
     haveNviz = True
-except (ImportError, NameError), err:
+except (ImportError, NameError) as err:
     haveNviz = False
     haveNviz = False
     errorMsg = err
     errorMsg = err
 
 

+ 2 - 2
gui/wxpython/nviz/mapwindow.py

@@ -1348,7 +1348,7 @@ class GLWindow(MapWindowBase, glcanvas.GLCanvas):
                     if vInfo['map3d'] and (vInfo['kernels'] + vInfo['faces']) > 0:
                     if vInfo['map3d'] and (vInfo['kernels'] + vInfo['faces']) > 0:
                         self.LoadVector(item, points=None)
                         self.LoadVector(item, points=None)
                     
                     
-            except GException, e:
+            except GException as e:
                 GError(parent = self,
                 GError(parent = self,
                        message = e.value)
                        message = e.value)
         
         
@@ -1390,7 +1390,7 @@ class GLWindow(MapWindowBase, glcanvas.GLCanvas):
                     if (vInfo['lines'] + vInfo['boundaries']) > 0 or vInfo['map3d']:
                     if (vInfo['lines'] + vInfo['boundaries']) > 0 or vInfo['map3d']:
                         self.UnloadVector(layer, points = False)
                         self.UnloadVector(layer, points = False)
                         
                         
-            except GException, e:
+            except GException as e:
                 GError(parent = self,
                 GError(parent = self,
                        message = e.value)
                        message = e.value)
         
         

+ 1 - 1
gui/wxpython/nviz/tools.py

@@ -2778,7 +2778,7 @@ class NvizToolWindow(FN.FlatNotebook):
         name = event.GetString()
         name = event.GetString()
         try:
         try:
             data = self._getLayerPropertiesByName(name, mapType = 'raster')['surface']
             data = self._getLayerPropertiesByName(name, mapType = 'raster')['surface']
-        except TypeError, e:
+        except TypeError as e:
             self.EnablePage('surface', False)
             self.EnablePage('surface', False)
             return
             return
 
 

+ 1 - 1
gui/wxpython/psmap/dialogs.py

@@ -4315,7 +4315,7 @@ class ImageDialog(PsmapDialog):
                     import types
                     import types
                     pImg.load = types.MethodType(loadPSForWindows, pImg)
                     pImg.load = types.MethodType(loadPSForWindows, pImg)
                 img = PilImageToWxImage(pImg)
                 img = PilImageToWxImage(pImg)
-            except IOError, e:
+            except IOError as e:
                 GError(message = _("Unable to read file %s") % file)
                 GError(message = _("Unable to read file %s") % file)
                 self.ClearPreview()
                 self.ClearPreview()
                 return
                 return

+ 2 - 2
gui/wxpython/psmap/frame.py

@@ -323,7 +323,7 @@ class PsMapFrame(wx.Frame):
                                                                                         'code': ret})
                                                                                         'code': ret})
                 else:
                 else:
                     self.SetStatusText(_('PDF generated'), 0)
                     self.SetStatusText(_('PDF generated'), 0)
-            except OSError, e:
+            except OSError as e:
                 GError(parent = self,
                 GError(parent = self,
                        message = _("Program ps2pdf is not available. Please install it to create PDF.\n\n %s") % e)
                        message = _("Program ps2pdf is not available. Please install it to create PDF.\n\n %s") % e)
 
 
@@ -346,7 +346,7 @@ class PsMapFrame(wx.Frame):
                     import types
                     import types
                     im.load = types.MethodType(loadPSForWindows, im)
                     im.load = types.MethodType(loadPSForWindows, im)
                 im.save(self.imgName, format = 'PNG')
                 im.save(self.imgName, format = 'PNG')
-            except IOError, e:
+            except IOError as e:
                 del busy
                 del busy
                 dlg = HyperlinkDialog(self, title=_("Preview not available"),
                 dlg = HyperlinkDialog(self, title=_("Preview not available"),
                                       message=_("Preview is not available probably due to missing Ghostscript."),
                                       message=_("Preview is not available probably due to missing Ghostscript."),

+ 6 - 6
gui/wxpython/psmap/instructions.py

@@ -468,7 +468,7 @@ class Instruction:
         try:
         try:
             RunCommand(cmd[0], **cmd[1])
             RunCommand(cmd[0], **cmd[1])
             
             
-        except grass.ScriptError, e:
+        except grass.ScriptError as e:
             GError(_("Region cannot be set\n%s") % e)
             GError(_("Region cannot be set\n%s") % e)
             return False
             return False
         
         
@@ -809,7 +809,7 @@ class Text(InstructionObject):
         instr += "    end"
         instr += "    end"
         try:
         try:
             instr = instr.encode('latin1')
             instr = instr.encode('latin1')
-        except UnicodeEncodeError, err:
+        except UnicodeEncodeError as err:
             try:
             try:
                 pos = str(err).split('position')[1].split(':')[0].strip()
                 pos = str(err).split('position')[1].split(':')[0].strip()
             except IndexError:
             except IndexError:
@@ -1542,7 +1542,7 @@ class Raster(InstructionObject):
             return False
             return False
         try:
         try:
             info = grass.find_file(map, element = 'cell')
             info = grass.find_file(map, element = 'cell')
-        except grass.ScriptError, e:
+        except grass.ScriptError as e:
             GError(message = e.value)
             GError(message = e.value)
             return False
             return False
         instr['raster'] = info['fullname']
         instr['raster'] = info['fullname']
@@ -1580,7 +1580,7 @@ class Vector(InstructionObject):
                 vmap = line.split()[1]
                 vmap = line.split()[1]
                 try:
                 try:
                     info = grass.find_file(vmap, element = 'vector')
                     info = grass.find_file(vmap, element = 'vector')
-                except grass.ScriptError, e:
+                except grass.ScriptError as e:
                     GError(message = e.value)
                     GError(message = e.value)
                     return False
                     return False
                 vmap = info['fullname']
                 vmap = info['fullname']
@@ -1691,7 +1691,7 @@ class VProperties(InstructionObject):
         vInstruction += "    end"
         vInstruction += "    end"
         try:
         try:
             vInstruction = vInstruction.encode('Latin_1')
             vInstruction = vInstruction.encode('Latin_1')
-        except UnicodeEncodeError, err:
+        except UnicodeEncodeError as err:
             try:
             try:
                 pos = str(err).split('position')[1].split(':')[0].strip()
                 pos = str(err).split('position')[1].split(':')[0].strip()
             except IndexError:
             except IndexError:
@@ -1713,7 +1713,7 @@ class VProperties(InstructionObject):
         instr = {}
         instr = {}
         try:
         try:
             info = grass.find_file(name = text[0].split()[1], element = 'vector')
             info = grass.find_file(name = text[0].split()[1], element = 'vector')
-        except grass.ScriptError, e:
+        except grass.ScriptError as e:
             GError(message = e.value)
             GError(message = e.value)
             return False
             return False
         instr['name'] = info['fullname']
         instr['name'] = info['fullname']

+ 1 - 1
gui/wxpython/timeline/g.gui.timeline.py

@@ -45,7 +45,7 @@ from core.utils import _, GuiModuleMain
 def main():
 def main():
     try:
     try:
         from timeline.frame import TimelineFrame
         from timeline.frame import TimelineFrame
-    except ImportError, e:
+    except ImportError as e:
         grass.fatal(e.message)
         grass.fatal(e.message)
 
 
     datasets = options['inputs'].strip().split(',')
     datasets = options['inputs'].strip().split(',')

+ 1 - 1
gui/wxpython/tools/update_menudata.py

@@ -53,7 +53,7 @@ def parseModules():
             continue
             continue
         try:
         try:
             interface = gtask.parse_interface(module)
             interface = gtask.parse_interface(module)
-        except Exception, e:
+        except Exception as e:
             grass.error(module + ': ' + str(e))
             grass.error(module + ': ' + str(e))
             continue
             continue
         modules[interface.name] = { 'label'   : interface.label,
         modules[interface.name] = { 'label'   : interface.label,

+ 1 - 1
gui/wxpython/vdigit/main.py

@@ -18,7 +18,7 @@ try:
     from vdigit.wxdigit import IVDigit, GV_LINES, CFUNCTYPE
     from vdigit.wxdigit import IVDigit, GV_LINES, CFUNCTYPE
     haveVDigit = True
     haveVDigit = True
     errorMsg   = ''
     errorMsg   = ''
-except (ImportError, NameError), err:
+except (ImportError, NameError) as err:
     haveVDigit = False
     haveVDigit = False
     errorMsg   = err
     errorMsg   = err
     GV_LINES   = -1
     GV_LINES   = -1

+ 2 - 2
gui/wxpython/wxgui.py

@@ -118,10 +118,10 @@ def main(argv = None):
         try:
         try:
             opts, args = getopt.getopt(argv[1:], "hw:",
             opts, args = getopt.getopt(argv[1:], "hw:",
                                        ["help", "workspace"])
                                        ["help", "workspace"])
-        except getopt.error, msg:
+        except getopt.error as msg:
             raise Usage(msg)
             raise Usage(msg)
     
     
-    except Usage, err:
+    except Usage as err:
         print >> sys.stderr, err.msg
         print >> sys.stderr, err.msg
         print >> sys.stderr, "for help use --help"
         print >> sys.stderr, "for help use --help"
         printHelp()
         printHelp()

+ 1 - 1
gui/wxpython/wxplot/base.py

@@ -21,7 +21,7 @@ import sys
 import wx
 import wx
 try:
 try:
     import wx.lib.plot as plot
     import wx.lib.plot as plot
-except ImportError, e:
+except ImportError as e:
     print >> sys.stderr, e
     print >> sys.stderr, e
 
 
 from core.globalvar    import ICONDIR
 from core.globalvar    import ICONDIR

+ 2 - 2
gui/wxpython/wxplot/histogram.py

@@ -20,7 +20,7 @@ import sys
 import wx
 import wx
 try:
 try:
     import wx.lib.plot as plot
     import wx.lib.plot as plot
-except ImportError, e:
+except ImportError as e:
     print >> sys.stderr, e
     print >> sys.stderr, e
 
 
 import grass.script as grass
 import grass.script as grass
@@ -182,7 +182,7 @@ class HistogramPlotFrame(BasePlotFrame):
                 datalist.append((cellval,histval))
                 datalist.append((cellval,histval))
 
 
             return datalist
             return datalist
-        except GException, e:
+        except GException as e:
             GError(parent = self,
             GError(parent = self,
                    message = e.value)
                    message = e.value)
             return None
             return None

+ 2 - 2
gui/wxpython/wxplot/profile.py

@@ -22,7 +22,7 @@ import math
 import wx
 import wx
 try:
 try:
     import wx.lib.plot as plot
     import wx.lib.plot as plot
-except ImportError, e:
+except ImportError as e:
     print >> sys.stderr, e
     print >> sys.stderr, e
 
 
 import grass.script as grass
 import grass.script as grass
@@ -356,7 +356,7 @@ class ProfileFrame(BasePlotFrame):
                 
                 
                 try:
                 try:
                     fd = open(pfile[-1], "w")
                     fd = open(pfile[-1], "w")
-                except IOError, e:
+                except IOError as e:
                     GError(parent = self,
                     GError(parent = self,
                            message = _("Unable to open file <%s> for writing.\n"
                            message = _("Unable to open file <%s> for writing.\n"
                                        "Reason: %s") % (pfile[-1], e))
                                        "Reason: %s") % (pfile[-1], e))

+ 2 - 2
gui/wxpython/wxplot/scatter.py

@@ -20,7 +20,7 @@ import sys
 import wx
 import wx
 try:
 try:
     import wx.lib.plot as plot
     import wx.lib.plot as plot
-except ImportError, e:
+except ImportError as e:
     print >> sys.stderr, e
     print >> sys.stderr, e
 
 
 import grass.script as grass
 import grass.script as grass
@@ -188,7 +188,7 @@ class ScatterFrame(BasePlotFrame):
                 datalist.append((rast1,rast2))
                 datalist.append((rast1,rast2))
 
 
             return datalist
             return datalist
-        except GException, e:
+        except GException as e:
             GError(parent = self,
             GError(parent = self,
                    message = e.value)
                    message = e.value)
             return None
             return None

+ 4 - 4
lib/init/grass.py

@@ -650,7 +650,7 @@ def non_interactive(arg, geofile=None):
                             # create location using georeferenced file
                             # create location using georeferenced file
                             grass.create_location(gisdbase, location_name,
                             grass.create_location(gisdbase, location_name,
                                                   filename=geofile)
                                                   filename=geofile)
-                    except grass.ScriptError, e:
+                    except grass.ScriptError as e:
                         fatal(e.value.strip('"').strip("'").replace('\\n',
                         fatal(e.value.strip('"').strip("'").replace('\\n',
                                                                    os.linesep))
                                                                    os.linesep))
                 else:
                 else:
@@ -812,7 +812,7 @@ def set_language():
     
     
     try:
     try:
         locale.setlocale(locale.LC_ALL, language)
         locale.setlocale(locale.LC_ALL, language)
-    except locale.Error, e:
+    except locale.Error as e:
         try:
         try:
             # Locale lang.encoding might be missing. Let's try
             # Locale lang.encoding might be missing. Let's try
             # UTF-8 encoding before giving up as on Linux systems
             # UTF-8 encoding before giving up as on Linux systems
@@ -820,12 +820,12 @@ def set_language():
             # ISO-8859 ones.
             # ISO-8859 ones.
             language = locale.normalize('%s.UTF-8' % (language))
             language = locale.normalize('%s.UTF-8' % (language))
             locale.setlocale(locale.LC_ALL, language)
             locale.setlocale(locale.LC_ALL, language)
-        except locale.Error, e:
+        except locale.Error as e:
             # The last attempt...
             # The last attempt...
             try:
             try:
                 language = locale.normalize('%s.%s' % (language, locale.getpreferredencoding()))
                 language = locale.normalize('%s.%s' % (language, locale.getpreferredencoding()))
                 locale.setlocale(locale.LC_ALL, language)
                 locale.setlocale(locale.LC_ALL, language)
-            except locale.Error, e:
+            except locale.Error as e:
                 # If we got so far, attempts to set up language and locale have failed
                 # If we got so far, attempts to set up language and locale have failed
                 # on this system
                 # on this system
                 sys.stderr.write("Failed to enforce user specified language '%s' with error: '%s'\n" % (language, e))
                 sys.stderr.write("Failed to enforce user specified language '%s' with error: '%s'\n" % (language, e))

+ 1 - 1
lib/python/ctypes/ctypesgencore/libraryloader.py

@@ -67,7 +67,7 @@ class LibraryLoader(object):
                 return ctypes.CDLL(path, ctypes.RTLD_GLOBAL)
                 return ctypes.CDLL(path, ctypes.RTLD_GLOBAL)
             else:
             else:
                 return ctypes.cdll.LoadLibrary(path)
                 return ctypes.cdll.LoadLibrary(path)
-        except OSError,e:
+        except OSError as e:
             raise ImportError,e
             raise ImportError,e
     
     
     def getpaths(self,libname):
     def getpaths(self,libname):

+ 3 - 3
lib/python/ctypes/ctypesgencore/parser/lex.py

@@ -455,7 +455,7 @@ def _form_master_re(relist,reflags,ldict):
                     lexindexfunc[i] = (None, f[2:])
                     lexindexfunc[i] = (None, f[2:])
          
          
         return [(lexre,lexindexfunc)],[regex]
         return [(lexre,lexindexfunc)],[regex]
-    except Exception,e:
+    except Exception as e:
         m = int(len(relist)/2)
         m = int(len(relist)/2)
         if m == 0: m = 1
         if m == 0: m = 1
         llist, lre = _form_master_re(relist[:m],reflags,ldict)
         llist, lre = _form_master_re(relist[:m],reflags,ldict)
@@ -702,7 +702,7 @@ def lex(module=None,object=None,debug=0,optimize=0,lextab="lextab",reflags=0,now
                              print "%s:%d: Regular expression for rule '%s' matches empty string." % (file,line,f.__name__)
                              print "%s:%d: Regular expression for rule '%s' matches empty string." % (file,line,f.__name__)
                              error = 1
                              error = 1
                              continue
                              continue
-                    except re.error,e:
+                    except re.error as e:
                         print "%s:%d: Invalid regular expression for rule '%s'. %s" % (file,line,f.__name__,e)
                         print "%s:%d: Invalid regular expression for rule '%s'. %s" % (file,line,f.__name__,e)
                         if '#' in f.__doc__:
                         if '#' in f.__doc__:
                              print "%s:%d. Make sure '#' in rule '%s' is escaped with '\\#'." % (file,line, f.__name__)                 
                              print "%s:%d. Make sure '#' in rule '%s' is escaped with '\\#'." % (file,line, f.__name__)                 
@@ -743,7 +743,7 @@ def lex(module=None,object=None,debug=0,optimize=0,lextab="lextab",reflags=0,now
                          print "lex: Regular expression for rule '%s' matches empty string." % name
                          print "lex: Regular expression for rule '%s' matches empty string." % name
                          error = 1
                          error = 1
                          continue
                          continue
-                except re.error,e:
+                except re.error as e:
                     print "lex: Invalid regular expression for rule '%s'. %s" % (name,e)
                     print "lex: Invalid regular expression for rule '%s'. %s" % (name,e)
                     if '#' in r:
                     if '#' in r:
                          print "lex: Make sure '#' in rule '%s' is escaped with '\\#'." % name
                          print "lex: Make sure '#' in rule '%s' is escaped with '\\#'." % name

+ 2 - 2
lib/python/ctypes/ctypesgencore/parser/pplexer.py

@@ -59,12 +59,12 @@ class StringLiteral(str):
         # Unescaping probably not perfect but close enough.
         # Unescaping probably not perfect but close enough.
         try:
         try:
             value = value[1:-1].decode('string_escape')
             value = value[1:-1].decode('string_escape')
-        except ValueError, e:
+        except ValueError as e:
             try:
             try:
                 value = re.sub(r'\\x([0-9a-fA-F])(?![0-9a-fA-F])',
                 value = re.sub(r'\\x([0-9a-fA-F])(?![0-9a-fA-F])',
                                r'\x0\1',
                                r'\x0\1',
                                value[1:-1]).decode('string_escape')
                                value[1:-1]).decode('string_escape')
-            except ValueError, e:
+            except ValueError as e:
                 raise ValueError("invalid \\x escape in %s" % value)
                 raise ValueError("invalid \\x escape in %s" % value)
         return str.__new__(cls, value)
         return str.__new__(cls, value)
 
 

+ 4 - 4
lib/python/ctypes/ctypesgencore/parser/yacc.py

@@ -615,7 +615,7 @@ class Production:
         # Precompute list of productions immediately following
         # Precompute list of productions immediately following
         try:
         try:
             p.lrafter = Prodnames[p.prod[n+1]]
             p.lrafter = Prodnames[p.prod[n+1]]
-        except (IndexError,KeyError),e:
+        except (IndexError,KeyError) as e:
             p.lrafter = []
             p.lrafter = []
         try:
         try:
             p.lrbefore = p.prod[n-1]
             p.lrbefore = p.prod[n-1]
@@ -1785,7 +1785,7 @@ def lr_parse_table(method):
                                 action[st,a] = j
                                 action[st,a] = j
                                 actionp[st,a] = p
                                 actionp[st,a] = p
                                 
                                 
-            except StandardError,e:
+            except StandardError as e:
                 raise YaccError, "Hosed in lr_parse_table", e
                 raise YaccError, "Hosed in lr_parse_table", e
 
 
         # Print the actions associated with each terminal
         # Print the actions associated with each terminal
@@ -1948,7 +1948,7 @@ del _lr_goto_items
         
         
         f.close()
         f.close()
 
 
-    except IOError,e:
+    except IOError as e:
         print "Unable to create '%s'" % filename
         print "Unable to create '%s'" % filename
         print e
         print e
         return
         return
@@ -2194,7 +2194,7 @@ def yacc(method=default_lr, debug=yaccdebug, module=None, tabmodule=tab_module,
                     f.write("\n\n")
                     f.write("\n\n")
                     f.write(_vf.getvalue())
                     f.write(_vf.getvalue())
                     f.close()
                     f.close()
-                except IOError,e:
+                except IOError as e:
                     print "yacc: can't create '%s'" % debugfile,e
                     print "yacc: can't create '%s'" % debugfile,e
         
         
     # Made it here.   Create a parser object and set up its internal state.
     # Made it here.   Create a parser object and set up its internal state.

+ 1 - 1
lib/python/ctypes/ctypesgencore/processor/operations.py

@@ -189,7 +189,7 @@ def find_source_libraries(data,opts):
     for library_name in opts.libraries:
     for library_name in opts.libraries:
         try:
         try:
             library=ctypesgencore.libraryloader.load_library(library_name)
             library=ctypesgencore.libraryloader.load_library(library_name)
-        except ImportError,e:
+        except ImportError as e:
             warning_message("Could not load library \"%s\". Okay, I'll " \
             warning_message("Could not load library \"%s\". Okay, I'll " \
                 "try to load it at runtime instead. " % (library_name),
                 "try to load it at runtime instead. " % (library_name),
                 cls = 'missing-library')
                 cls = 'missing-library')

+ 1 - 1
lib/python/ctypes/loader.py

@@ -67,7 +67,7 @@ class LibraryLoader(object):
                 return ctypes.CDLL(path, ctypes.RTLD_GLOBAL)
                 return ctypes.CDLL(path, ctypes.RTLD_GLOBAL)
             else:
             else:
                 return ctypes.cdll.LoadLibrary(path)
                 return ctypes.cdll.LoadLibrary(path)
-        except OSError,e:
+        except OSError as e:
             raise ImportError,e
             raise ImportError,e
     
     
     def getpaths(self,libname):
     def getpaths(self,libname):

+ 1 - 1
lib/python/pydispatch/robust.py

@@ -50,7 +50,7 @@ def sendRobust(
 				*arguments,
 				*arguments,
 				**named
 				**named
 			)
 			)
-		except Exception, err:
+		except Exception as err:
 			responses.append((receiver, err))
 			responses.append((receiver, err))
 		else:
 		else:
 			responses.append((receiver, response))
 			responses.append((receiver, response))

+ 1 - 1
lib/python/pydispatch/saferef.py

@@ -115,7 +115,7 @@ class BoundMethodWeakref(object):
 				try:
 				try:
 					if hasattr(function, '__call__' ):
 					if hasattr(function, '__call__' ):
 						function( self )
 						function( self )
-				except Exception, e:
+				except Exception as e:
 					try:
 					try:
 						traceback.print_exc()
 						traceback.print_exc()
 					except AttributeError:
 					except AttributeError:

+ 2 - 2
lib/python/script/core.py

@@ -1602,7 +1602,7 @@ def create_location(dbase, location, epsg=None, proj4=None, filename=None,
         else:
         else:
             fd.write(os.linesep)
             fd.write(os.linesep)
         fd.close()
         fd.close()
-    except OSError, e:
+    except OSError as e:
         raise ScriptError(repr(e))
         raise ScriptError(repr(e))
 
 
 
 
@@ -1650,7 +1650,7 @@ def _create_location_xy(database, location):
                     os.path.join(location, "PERMANENT", "WIND"))
                     os.path.join(location, "PERMANENT", "WIND"))
 
 
         os.chdir(cur_dir)
         os.chdir(cur_dir)
-    except OSError, e:
+    except OSError as e:
         raise ScriptError(repr(e))
         raise ScriptError(repr(e))
 
 
 # interface to g.version
 # interface to g.version

+ 2 - 2
lib/python/script/task.py

@@ -66,7 +66,7 @@ class grassTask:
             try:
             try:
                 processTask(tree = etree.fromstring(get_interface_description(path)),
                 processTask(tree = etree.fromstring(get_interface_description(path)),
                             task = self)
                             task = self)
-            except ScriptError, e:
+            except ScriptError as e:
                 self.errorMsg = e.value
                 self.errorMsg = e.value
             
             
             self.define_first()
             self.define_first()
@@ -486,7 +486,7 @@ def get_interface_description(cmd):
             raise ScriptError, _("Unable to fetch interface description for command '%(cmd)s'."
             raise ScriptError, _("Unable to fetch interface description for command '%(cmd)s'."
                                  "\n\nDetails: %(det)s") % { 'cmd' : cmd, 'det' : decode(cmderr) }
                                  "\n\nDetails: %(det)s") % { 'cmd' : cmd, 'det' : decode(cmderr) }
     
     
-    except OSError, e:
+    except OSError as e:
         raise ScriptError, _("Unable to fetch interface description for command '%(cmd)s'."
         raise ScriptError, _("Unable to fetch interface description for command '%(cmd)s'."
                              "\n\nDetails: %(det)s") % { 'cmd' : cmd, 'det' : e }
                              "\n\nDetails: %(det)s") % { 'cmd' : cmd, 'det' : e }
     
     

+ 1 - 1
lib/python/temporal/gui_support.py

@@ -46,7 +46,7 @@ def tlist_grouped(type, group_type = False, dbif=None):
     for type in types:
     for type in types:
         try:
         try:
             tlist_result = tlist(type=type, dbif=dbif)
             tlist_result = tlist(type=type, dbif=dbif)
-        except core.ScriptError, e:
+        except core.ScriptError as e:
             warning(e)
             warning(e)
             continue
             continue
 
 

+ 2 - 2
man/build_html.py

@@ -302,7 +302,7 @@ def write_file(name, contents):
 def try_mkdir(path):
 def try_mkdir(path):
     try:
     try:
         os.mkdir(path)
         os.mkdir(path)
-    except OSError, e:
+    except OSError as e:
         pass
         pass
 
 
 def replace_file(name):
 def replace_file(name):
@@ -312,7 +312,7 @@ def replace_file(name):
     else:
     else:
         try:
         try:
             os.remove(name)
             os.remove(name)
-        except OSError, e:
+        except OSError as e:
             pass
             pass
         os.rename(temp, name)
         os.rename(temp, name)
 
 

+ 2 - 2
man/build_rest.py

@@ -278,7 +278,7 @@ def write_file(name, contents):
 def try_mkdir(path):
 def try_mkdir(path):
     try:
     try:
         os.mkdir(path)
         os.mkdir(path)
-    except OSError, e:
+    except OSError as e:
         pass
         pass
 
 
 def replace_file(name):
 def replace_file(name):
@@ -288,7 +288,7 @@ def replace_file(name):
     else:
     else:
         try:
         try:
             os.remove(name)
             os.remove(name)
-        except OSError, e:
+        except OSError as e:
             pass
             pass
         os.rename(temp, name)
         os.rename(temp, name)
 
 

+ 2 - 2
scripts/d.redraw/d.redraw.py

@@ -51,7 +51,7 @@ def main():
         
         
         for cmd in cmdList:
         for cmd in cmdList:
             grass.call(split(cmd))
             grass.call(split(cmd))
-    except IOError, e:
+    except IOError as e:
         grass.fatal(_("Unable to open file '%s' for reading. Details: %s") % \
         grass.fatal(_("Unable to open file '%s' for reading. Details: %s") % \
                         (monCmd, e))
                         (monCmd, e))
     
     
@@ -61,7 +61,7 @@ def main():
     try:
     try:
         fd = open(monCmd, "w")
         fd = open(monCmd, "w")
         fd.writelines(cmdList)
         fd.writelines(cmdList)
-    except IOError, e:
+    except IOError as e:
         grass.fatal(_("Unable to open file '%s' for writing. Details: %s") % \
         grass.fatal(_("Unable to open file '%s' for writing. Details: %s") % \
                         (monCmd, e))
                         (monCmd, e))
     
     

+ 1 - 1
scripts/g.extension.all/g.extension.all.py

@@ -58,7 +58,7 @@ def get_extensions():
     fo = open(fXML, 'r')
     fo = open(fXML, 'r')
     try:
     try:
         tree = etree.fromstring(fo.read())
         tree = etree.fromstring(fo.read())
-    except StandardError, e:
+    except StandardError as e:
         grass.error(_("Unable to parse metadata file: %s") % e)
         grass.error(_("Unable to parse metadata file: %s") % e)
         fo.close()
         fo.close()
         return []
         return []

+ 4 - 4
scripts/g.extension/g.extension.py

@@ -935,7 +935,7 @@ def check_style_files(fil):
 
 
     try:
     try:
         shutil.copyfile(dist_file, addons_file)
         shutil.copyfile(dist_file, addons_file)
-    except OSError, e:
+    except OSError as e:
         grass.fatal(_("Unable to create '%s': %s") % (addons_file, e))
         grass.fatal(_("Unable to create '%s': %s") % (addons_file, e))
 
 
 def create_dir(path):
 def create_dir(path):
@@ -944,7 +944,7 @@ def create_dir(path):
 
 
     try:
     try:
         os.makedirs(path)
         os.makedirs(path)
-    except OSError, e:
+    except OSError as e:
         grass.fatal(_("Unable to create '%s': %s") % (path, e))
         grass.fatal(_("Unable to create '%s': %s") % (path, e))
 
 
     grass.debug("'%s' created" % path)
     grass.debug("'%s' created" % path)
@@ -970,7 +970,7 @@ def update_manual_page(module):
     try:
     try:
         f = open(htmlfile)
         f = open(htmlfile)
         shtml = f.read()
         shtml = f.read()
-    except IOError, e:
+    except IOError as e:
         grass.fatal(_("Unable to read manual page: %s") % e)
         grass.fatal(_("Unable to read manual page: %s") % e)
     else:
     else:
         f.close()
         f.close()
@@ -1000,7 +1000,7 @@ def update_manual_page(module):
     try:
     try:
         f = open(htmlfile, 'w')
         f = open(htmlfile, 'w')
         f.write(ohtml)
         f.write(ohtml)
-    except IOError, e:
+    except IOError as e:
         grass.fatal(_("Unable for write manual page: %s") % e)
         grass.fatal(_("Unable for write manual page: %s") % e)
     else:
     else:
         f.close()
         f.close()

+ 2 - 2
scripts/r.in.wms/wms_base.py

@@ -219,7 +219,7 @@ class WMSBase:
 
 
         try:
         try:
             cap = self._fetchDataFromServer(cap_url, options['username'], options['password'])
             cap = self._fetchDataFromServer(cap_url, options['username'], options['password'])
-        except (IOError, HTTPException), e:
+        except (IOError, HTTPException) as e:
             if urllib2.HTTPError == type(e) and e.code == 401:
             if urllib2.HTTPError == type(e) and e.code == 401:
                 grass.fatal(_("Authorization failed to <%s> when fetching capabilities") % options['url'])
                 grass.fatal(_("Authorization failed to <%s> when fetching capabilities") % options['url'])
             else:
             else:
@@ -380,7 +380,7 @@ class WMSBase:
                                       '-r', gdal_method,
                                       '-r', gdal_method,
                                       self.temp_map, self.temp_warpmap], stdout = nuldev)
                                       self.temp_map, self.temp_warpmap], stdout = nuldev)
                 ps.wait()
                 ps.wait()
-            except OSError, e:
+            except OSError as e:
                 grass.fatal('%s \nThis can be caused by missing %s utility. ' % (e, 'gdalwarp'))
                 grass.fatal('%s \nThis can be caused by missing %s utility. ' % (e, 'gdalwarp'))
             
             
             if nuldev:
             if nuldev:

+ 3 - 3
scripts/r.in.wms/wms_drv.py

@@ -95,7 +95,7 @@ class WMSDrv(WMSBase):
             grass.debug(query_url, 2)
             grass.debug(query_url, 2)
             try: 
             try: 
                 wms_data = self._fetchDataFromServer(query_url, self.params['username'], self.params['password'])
                 wms_data = self._fetchDataFromServer(query_url, self.params['username'], self.params['password'])
-            except (IOError, HTTPException), e:
+            except (IOError, HTTPException) as e:
                 if HTTPError == type(e) and e.code == 401:
                 if HTTPError == type(e) and e.code == 401:
                     grass.fatal(_("Authorization failed to '%s' when fetching data.\n%s") % (self.params['url'], str(e)))
                     grass.fatal(_("Authorization failed to '%s' when fetching data.\n%s") % (self.params['url'], str(e)))
                 else:
                 else:
@@ -107,7 +107,7 @@ class WMSDrv(WMSBase):
             try:
             try:
                 temp_tile_opened = open(temp_tile, 'wb')
                 temp_tile_opened = open(temp_tile, 'wb')
                 temp_tile_opened.write(wms_data.read())
                 temp_tile_opened.write(wms_data.read())
-            except IOError, e:
+            except IOError as e:
                 # some servers are not happy with many subsequent requests for tiles done immediately,
                 # some servers are not happy with many subsequent requests for tiles done immediately,
                 # if immediate request was unsuccessful, try to repeat the request after 5s and 30s breaks
                 # if immediate request was unsuccessful, try to repeat the request after 5s and 30s breaks
                 # TODO probably servers can return more kinds of errors related to this problem (not only 104)
                 # TODO probably servers can return more kinds of errors related to this problem (not only 104)
@@ -136,7 +136,7 @@ class WMSDrv(WMSBase):
                 try:
                 try:
                     error_xml_opened = open(temp_tile, 'rb')
                     error_xml_opened = open(temp_tile, 'rb')
                     err_str = error_xml_opened.read()     
                     err_str = error_xml_opened.read()     
-                except IOError, e:
+                except IOError as e:
                     grass.fatal(_("Unable to read data from tempfile.\n%s") % str(e))
                     grass.fatal(_("Unable to read data from tempfile.\n%s") % str(e))
                 finally:
                 finally:
                     error_xml_opened.close()
                     error_xml_opened.close()

+ 1 - 1
scripts/r.pack/r.pack.py

@@ -111,7 +111,7 @@ def main():
     tar.close()
     tar.close()
     try:
     try:
         shutil.move(outfile_base, outfile)
         shutil.move(outfile_base, outfile)
-    except shutil.Error, e:
+    except shutil.Error as e:
         grass.fatal(e)
         grass.fatal(e)
         
         
     os.chdir(olddir)
     os.chdir(olddir)

+ 1 - 1
scripts/v.krige/v.krige.py

@@ -349,7 +349,7 @@ def main(argv = None):
         if options['model'] is '':
         if options['model'] is '':
             try:
             try:
                 robjects.r.require("automap")
                 robjects.r.require("automap")
-            except ImportError, e:
+            except ImportError as e:
                 grass.fatal(_("R package automap is missing, no variogram autofit available."))
                 grass.fatal(_("R package automap is missing, no variogram autofit available."))
         else:
         else:
             if options['sill'] is '' or options['nugget'] is '' or options['range'] is '':
             if options['sill'] is '' or options['nugget'] is '' or options['range'] is '':

+ 1 - 1
temporal/t.register/t.register.py

@@ -127,5 +127,5 @@ if __name__ == "__main__":
 
 
     try:
     try:
         tgis.profile_function(main)
         tgis.profile_function(main)
-    except StandardError, e:
+    except StandardError as e:
         grass.fatal(e)
         grass.fatal(e)

+ 2 - 2
tools/g.html2man/g.html2man.py

@@ -34,10 +34,10 @@ def main():
     for n, line in enumerate(inf):
     for n, line in enumerate(inf):
 	try:
 	try:
 	    p.feed(line)
 	    p.feed(line)
-	except HTMLParseError, err:
+	except HTMLParseError as err:
 	    sys.stderr.write('%s:%d:%d: Parse error: %s\n' % (infile, err.lineno, err.offset, err.msg))
 	    sys.stderr.write('%s:%d:%d: Parse error: %s\n' % (infile, err.lineno, err.offset, err.msg))
 	    sys.exit(1)
 	    sys.exit(1)
-	except Exception, err:
+	except Exception as err:
 	    sys.stderr.write('%s:%d:0: Error (%s): %s\n' % (infile, n + 1, repr(err), line))
 	    sys.stderr.write('%s:%d:0: Error (%s): %s\n' % (infile, n + 1, repr(err), line))
 	    sys.exit(1)
 	    sys.exit(1)
     p.close()
     p.close()

+ 2 - 2
tools/reindent.py

@@ -70,7 +70,7 @@ def main():
     try:
     try:
         opts, args = getopt.getopt(sys.argv[1:], "drnvh",
         opts, args = getopt.getopt(sys.argv[1:], "drnvh",
                         ["dryrun", "recurse", "nobackup", "verbose", "help"])
                         ["dryrun", "recurse", "nobackup", "verbose", "help"])
-    except getopt.error, msg:
+    except getopt.error as msg:
         usage(msg)
         usage(msg)
         return
         return
     for o, a in opts:
     for o, a in opts:
@@ -111,7 +111,7 @@ def check(file):
         print "checking", file, "...",
         print "checking", file, "...",
     try:
     try:
         f = open(file)
         f = open(file)
-    except IOError, msg:
+    except IOError as msg:
         errprint("%s: I/O Error: %s" % (file, str(msg)))
         errprint("%s: I/O Error: %s" % (file, str(msg)))
         return
         return