From c3541efc708a110c16f0fb8685202d74608197cc Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Fri, 7 Jun 2019 20:53:10 -0700 Subject: [PATCH 1/6] IAccessible object: except COMError, e -> COMError as e. In Python 2, the exception statement of the form 'except exception, e' was acceptable, no longer the case in Python 3 (requires 'except exception as e'). Thus use the latter in IAccessible objects and others. --- source/NVDAObjects/IAccessible/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/NVDAObjects/IAccessible/__init__.py b/source/NVDAObjects/IAccessible/__init__.py index 0c51f653a99..c5877e2bf39 100644 --- a/source/NVDAObjects/IAccessible/__init__.py +++ b/source/NVDAObjects/IAccessible/__init__.py @@ -608,7 +608,7 @@ def __init__(self,windowHandle=None,IAccessibleObject=None,IAccessibleChildID=No try: left,top,width,height = IAccessibleObject.accLocation(0) windowHandle=winUser.user32.WindowFromPoint(winUser.POINT(left,top)) - except COMError, e: + except COMError as e: log.debugWarning("accLocation failed: %s" % e) if not windowHandle: raise InvalidNVDAObject("Can't get a window handle from IAccessible") From 4e302535e277d5abaf17a375915704233b20b614 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Fri, 7 Jun 2019 20:55:16 -0700 Subject: [PATCH 2/6] Adobe Flash object: except COMError, e -> COMError as e. --- source/NVDAObjects/IAccessible/adobeFlash.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/NVDAObjects/IAccessible/adobeFlash.py b/source/NVDAObjects/IAccessible/adobeFlash.py index 159b02921b6..64c0bf5ae5c 100644 --- a/source/NVDAObjects/IAccessible/adobeFlash.py +++ b/source/NVDAObjects/IAccessible/adobeFlash.py @@ -21,7 +21,7 @@ def _getStoryText(self): def _getRawSelectionOffsets(self): try: return self.obj.ISimpleTextSelectionObject.GetSelection() - except COMError, e: + except COMError as e: if e.hresult == hresult.E_FAIL: # The documentation says that an empty field should return 0 for both values, but instead, we seem to get E_FAIL. # An empty field still has a valid caret. From b09f82d07f36ad219f966bfcf3df9bd157af6711 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Fri, 7 Jun 2019 20:58:51 -0700 Subject: [PATCH 3/6] Log viewer: except (IOError, OSError), e -> (IOError, OSError) as e. --- source/gui/logViewer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/gui/logViewer.py b/source/gui/logViewer.py index 2f334396b2c..4b055cee689 100755 --- a/source/gui/logViewer.py +++ b/source/gui/logViewer.py @@ -83,7 +83,7 @@ def onSaveAsCommand(self, evt): # #9038: work with UTF-8 from the start. with open(filename, "w", encoding="UTF-8") as f: f.write(self.outputCtrl.GetValue()) - except (IOError, OSError), e: + except (IOError, OSError) as e: # Translators: Dialog text presented when NVDA cannot save a log file. gui.messageBox(_("Error saving log: %s") % e.strerror, _("Error"), style=wx.OK | wx.ICON_ERROR, parent=self) From bd174db96cee7c0263cd90e8e09af526daefa386 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Fri, 7 Jun 2019 21:00:35 -0700 Subject: [PATCH 4/6] Input core: except (configobj.ConfigObjError,UnicodeDecodeError), e -> (configobj.ConfigObjError,UnicodeDecodeError) as e. --- source/inputCore.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/inputCore.py b/source/inputCore.py index 602da3ef970..793b8917070 100644 --- a/source/inputCore.py +++ b/source/inputCore.py @@ -243,7 +243,7 @@ def load(self, filename): self.fileName = filename try: conf = configobj.ConfigObj(filename, file_error=True, encoding="UTF-8") - except (configobj.ConfigObjError,UnicodeDecodeError), e: + except (configobj.ConfigObjError,UnicodeDecodeError) as e: log.warning("Error in gesture map '%s': %s"%(filename, e)) self.lastUpdateContainedError = True return From 782b2236d1369aff8f01f1e60b08f2636b259555 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Fri, 7 Jun 2019 21:01:42 -0700 Subject: [PATCH 5/6] NVDA slave: except exception, e -> exception as e. --- source/nvda_slave.pyw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/nvda_slave.pyw b/source/nvda_slave.pyw index 632682b9ea3..d568d67ffe0 100755 --- a/source/nvda_slave.pyw +++ b/source/nvda_slave.pyw @@ -100,7 +100,7 @@ def main(): except installer.RetriableFailure: logHandler.log.error("Task failed, try again",exc_info=True) sys.exit(2) - except Exception, e: + except Exception as e: logHandler.log.error("slave error",exc_info=True) sys.exit(1) From b7f82df84f0b7ce6f06628fa0f44c9fc7ad1707c Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Fri, 7 Jun 2019 21:02:14 -0700 Subject: [PATCH 6/6] NVWave: except WindowsError, e -> WindowsError as e. --- source/nvwave.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/nvwave.py b/source/nvwave.py index 86e6b8719ff..076f25eafb1 100644 --- a/source/nvwave.py +++ b/source/nvwave.py @@ -214,7 +214,7 @@ def _feedUnbuffered(self, data, onDone=None): try: with self._global_waveout_lock: winmm.waveOutWrite(self._waveout, LPWAVEHDR(whdr), sizeof(WAVEHDR)) - except WindowsError, e: + except WindowsError as e: self.close() raise e self.sync()