diff --git a/source/NVDAObjects/__init__.py b/source/NVDAObjects/__init__.py index 729a68cd353..e2a454380c3 100644 --- a/source/NVDAObjects/__init__.py +++ b/source/NVDAObjects/__init__.py @@ -1098,7 +1098,7 @@ def _get_basicText(self): newTime=time.time() oldTime=getattr(self,'_basicTextTime',0) if newTime-oldTime>0.5: - self._basicText=u" ".join([x for x in self.name, self.value, self.description if isinstance(x, basestring) and len(x) > 0 and not x.isspace()]) + self._basicText=u" ".join(x for x in (self.name, self.value, self.description) if isinstance(x, basestring) and len(x) > 0 and not x.isspace()) if len(self._basicText)==0: self._basicText=u"" else: diff --git a/source/appModules/soffice.py b/source/appModules/soffice.py index 4aa10c775ae..478a84c2ddc 100755 --- a/source/appModules/soffice.py +++ b/source/appModules/soffice.py @@ -220,7 +220,7 @@ def _get_states(self): # #8988: Cells in Libre Office do not have the selected state when a single cell is selected (i.e. has focus). # Since #8898, the negative selected state is announced for table cells with the selectable state. states.add(controlTypes.STATE_SELECTED) - if self.IA2Attributes.get('Formula'): + if self.IA2Attributes.get('Formula'): # #860: Recent versions of Calc expose has formula state via IAccessible 2. states.add(controlTypes.STATE_HASFORMULA) return states diff --git a/source/baseObject.py b/source/baseObject.py index 3b338f73742..865ff75cd17 100755 --- a/source/baseObject.py +++ b/source/baseObject.py @@ -69,7 +69,7 @@ def __init__(self,name,bases,dict): s=dict.get('_set_%s'%x,None) d=dict.get('_del_%s'%x,None) if x in dict: - methodsString=",".join([str(i) for i in g,s,d if i]) + methodsString=",".join(str(i) for i in (g,s,d) if i) raise TypeError("%s is already a class attribute, cannot create descriptor with methods %s"%(x,methodsString)) if not g: # There's a setter or deleter, but no getter. diff --git a/source/characterProcessing.py b/source/characterProcessing.py index b10d21d2572..6a55f61dc8d 100644 --- a/source/characterProcessing.py +++ b/source/characterProcessing.py @@ -509,7 +509,7 @@ def __init__(self, locale): # Simple symbols. # These are all handled in one named group. # Because the symbols are just text, we know which symbol matched just by looking at the matched text. - patterns.append(ur"(?P{multiChars}|{singleChars})".format( + patterns.append(r"(?P{multiChars}|{singleChars})".format( multiChars="|".join(re.escape(identifier) for identifier in multiChars), singleChars=characters )) diff --git a/source/config/__init__.py b/source/config/__init__.py index d8431c20db7..2b74e16c28f 100644 --- a/source/config/__init__.py +++ b/source/config/__init__.py @@ -76,7 +76,7 @@ def saveOnExit(): def isInstalledCopy(): """Checks to see if this running copy of NVDA is installed on the system""" try: - k=winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\NVDA") + k=winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\NVDA") instDir=winreg.QueryValueEx(k,"UninstallDirectory")[0] except WindowsError: return False @@ -166,7 +166,7 @@ def initConfigPath(configPath=None): if not os.path.isdir(subdir): os.makedirs(subdir) -RUN_REGKEY = ur"SOFTWARE\Microsoft\Windows\CurrentVersion\Run" +RUN_REGKEY = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run" def getStartAfterLogon(): if (easeOfAccess.isSupported and easeOfAccess.canConfigTerminateOnDesktopSwitch @@ -234,7 +234,7 @@ def execElevated(path, params=None, wait=False,handleAlreadyElevated=False): #: The name of the registry key stored under HKEY_LOCAL_MACHINE where system wide NVDA settings are stored. #: Note that NVDA is a 32-bit application, so on X64 systems, this will evaluate to "SOFTWARE\WOW6432Node\nvda" -NVDA_REGKEY = ur"SOFTWARE\NVDA" +NVDA_REGKEY = r"SOFTWARE\NVDA" def getStartOnLogonScreen(): if easeOfAccess.isSupported and easeOfAccess.willAutoStart(winreg.HKEY_LOCAL_MACHINE): diff --git a/source/hwPortUtils.py b/source/hwPortUtils.py index f2c5e5f1769..6c70c8097f0 100644 --- a/source/hwPortUtils.py +++ b/source/hwPortUtils.py @@ -104,7 +104,7 @@ class dummy(ctypes.Structure): CR_SUCCESS = 0 MAX_DEVICE_ID_LEN = 200 -GUID_CLASS_COMPORT = GUID(0x86e0d1e0L, 0x8089, 0x11d0, +GUID_CLASS_COMPORT = GUID(0x86e0d1e0, 0x8089, 0x11d0, (ctypes.c_ubyte*8)(0x9c, 0xe4, 0x08, 0x00, 0x3e, 0x30, 0x1f, 0x73)) GUID_DEVINTERFACE_USB_DEVICE = GUID(0xA5DCBF10, 0x6530, 0x11D2, (0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED)) diff --git a/source/installer.py b/source/installer.py index 31741c6959c..cd53ddb85b6 100644 --- a/source/installer.py +++ b/source/installer.py @@ -74,7 +74,7 @@ def getStartMenuFolder(noDefault=False): def getInstallPath(noDefault=False): try: - k=winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\NVDA") + k=winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\NVDA") return winreg.QueryValueEx(k,"UninstallDirectory")[0] except WindowsError: return defaultInstallPath if not noDefault else None diff --git a/source/locationHelper.py b/source/locationHelper.py index 92575c50765..7f76bc61f49 100644 --- a/source/locationHelper.py +++ b/source/locationHelper.py @@ -6,7 +6,8 @@ """Classes and helper functions for working with rectangles and coordinates.""" -from collections import namedtuple, Sequence +from collections import namedtuple +from collections.abc import Sequence import windowUtils import winUser from ctypes.wintypes import RECT, POINT, DWORD diff --git a/source/logHandler.py b/source/logHandler.py index b9384f1caa0..15f5e15cefe 100755 --- a/source/logHandler.py +++ b/source/logHandler.py @@ -93,7 +93,7 @@ def getCodePath(f): className=cls.__name__ if className: break - return ".".join([x for x in path,className,funcName if x]) + return ".".join(x for x in (path,className,funcName) if x) # Function to strip the base path of our code from traceback text to improve readability. BASE_PATH = os.path.split(__file__)[0] + os.sep diff --git a/source/mathPres/mathPlayer.py b/source/mathPres/mathPlayer.py index e21627a4dd8..7b297f0520a 100644 --- a/source/mathPres/mathPlayer.py +++ b/source/mathPres/mathPlayer.py @@ -21,9 +21,9 @@ # Break. r" ?" # Pronunciation of characters. - ur"|(?P[^<]) ?" + r"|(?P[^<]) ?" # Specific pronunciation. - ur"| (?P[^ <]+) ?" + r"| (?P[^ <]+) ?" # Prosody. r"| ?" r"|(?P) ?" diff --git a/source/nvda.pyw b/source/nvda.pyw index 6fd8b66c7f2..538bfc5ccbc 100755 --- a/source/nvda.pyw +++ b/source/nvda.pyw @@ -179,7 +179,7 @@ isSecureDesktop = desktopName == "Winlogon" if isSecureDesktop: import winreg try: - k = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, ur"SOFTWARE\NVDA") + k = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\NVDA") if not winreg.QueryValueEx(k, u"serviceDebug")[0]: globalVars.appArgs.secure = True except WindowsError: diff --git a/source/setup.py b/source/setup.py index ed11c4c88b4..a1108d985eb 100755 --- a/source/setup.py +++ b/source/setup.py @@ -190,7 +190,19 @@ def getRecursiveDataFiles(dest,source,excludes=()): options = {"py2exe": { "bundle_files": 3, "excludes": ["tkinter", - "serial.loopback_connection", "serial.rfc2217", "serial.serialcli", "serial.serialjava", "serial.serialposix", "serial.socket_connection"], + "serial.loopback_connection", + "serial.rfc2217", + "serial.serialcli", + "serial.serialjava", + "serial.serialposix", + "serial.socket_connection", + # netbios (from pywin32) is optionally used by Python3's uuid module. + # This is not needed. + "netbios", + # winxptheme is optionally used by wx.lib.agw.aui. + # We don't need this. + "winxptheme", + ], "packages": ["NVDAObjects","virtualBuffers","appModules","comInterfaces","brailleDisplayDrivers","synthDrivers"], "includes": [ "nvdaBuiltin", diff --git a/source/speech/__init__.py b/source/speech/__init__.py index 6493809cd68..b3162c54cc1 100755 --- a/source/speech/__init__.py +++ b/source/speech/__init__.py @@ -1736,7 +1736,7 @@ def getTableInfoSpeech(tableInfo,oldTableInfo,extraDetail=False): textList.append(_("row %s")%rowNumber) return " ".join(textList) -re_last_pause=re.compile(ur"^(.*(?<=[^\s.!?])[.!?][\"'”’)]?(?:\s+|$))(.*$)",re.DOTALL|re.UNICODE) +re_last_pause=re.compile(r"^(.*(?<=[^\s.!?])[.!?][\"'”’)]?(?:\s+|$))(.*$)",re.DOTALL|re.UNICODE) def speakWithoutPauses(speechSequence,detectBreaks=True): """ diff --git a/source/virtualBuffers/__init__.py b/source/virtualBuffers/__init__.py index 195110a9eca..2e39ccb6264 100644 --- a/source/virtualBuffers/__init__.py +++ b/source/virtualBuffers/__init__.py @@ -50,8 +50,8 @@ class VBufStorage_findMatch_word(unicode): FINDBYATTRIBS_ESCAPE_TABLE = { # Symbols that are escaped in the attributes string. - ord(u":"): ur"\\:", - ord(u";"): ur"\\;", + ord(u":"): r"\\:", + ord(u";"): r"\\;", ord(u"\\"): u"\\\\\\\\", } # Symbols that must be escaped for a regular expression. diff --git a/source/watchdog.py b/source/watchdog.py index 9c80c90b19a..b554799cf8e 100644 --- a/source/watchdog.py +++ b/source/watchdog.py @@ -291,7 +291,11 @@ def execute(self, func, args, kwargs, pumpMessages=True): exc = self._exc_info if exc: - raise exc[0], exc[1], exc[2] + # The execution of the function in the other thread caused an exception. + # Re-raise it here. + # Note that in Python3, the traceback (stack) is now part of the exception, + # So the logged traceback will correctly show the stack for both this thread and the other thread. + raise exc return self._result def run(self): @@ -301,8 +305,8 @@ def run(self): self._executeEvent.clear() try: self._result = self._func(*self._args, **self._kwargs) - except: - self._exc_info = sys.exc_info() + except Exception as e: + self._exc_info = e ctypes.windll.kernel32.SetEvent(self._executionDoneEvent) ctypes.windll.kernel32.CloseHandle(self._executionDoneEvent) diff --git a/source/winKernel.py b/source/winKernel.py index 5484fbe5aba..b1e4b95cb4a 100644 --- a/source/winKernel.py +++ b/source/winKernel.py @@ -38,10 +38,10 @@ DATE_LONGDATE=0x00000002 TIME_NOSECONDS=0x00000002 # Wait return types -WAIT_ABANDONED = 0x00000080L -WAIT_IO_COMPLETION = 0x000000c0L -WAIT_OBJECT_0 = 0x00000000L -WAIT_TIMEOUT = 0x00000102L +WAIT_ABANDONED = 0x00000080 +WAIT_IO_COMPLETION = 0x000000c0 +WAIT_OBJECT_0 = 0x00000000 +WAIT_TIMEOUT = 0x00000102 WAIT_FAILED = 0xffffffff # Image file machine constants IMAGE_FILE_MACHINE_UNKNOWN = 0