internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: nvaccess/nvda

Issue:
Python 3: comtypes.client.PumpEvents raises error after timeout
### Steps to reproduce:
Open Outlook.
When there is a message in the open folder
Nvda shows a window called waiting for outlook.
It happens that in previous verifications of the nvda this window appears more exits automatically.
In the verdict of nvda that I am testing this window opens more does not date.
It only closes if I press alt + f4.
### Actual behavior:
the window waiting for the Outlook is displayed but does not close automatically
### Expected behavior:
the window waiting for the outlook is opened more automatically closes.
### System configuration
#### NVDA installed/portable/running from source:
install
#### NVDA version:
threshold_py3_staging-18054,92458e98
#### Windows version:
10 18362.175
#### Name and version of other software in use when reproducing the issue:
outlook Office 365 MSO (16.0.11629.20238) 64 bits 
#### Other information about your system:

### Other questions
#### Does the issue still occur after restarting your PC?
yes
#### Have you tried any other versions of NVDA? If so, please report their behaviors.
yes
alpha-17697,1d50498c
works correctly.
log:
[outlook.txt](https://github.com/nvaccess/nvda/files/3388011/outlook.txt)



Discussion:
Hi,

For those not speaking Portuguese, the traceback ends with:
OSError: [WinError -2147417835] OLE has sent a request and is waiting for a reply

Thanks.
I've seen this once now, but haven't found a reliable way to reproduce this.
It turns out that comtypes.client.PumpEvents raises an error after timing out. This can easily be reproduced from the python console.
The issue is in comtypes.client.events around line 278

```
        except WindowsError as details:
            if details.args[0] != RPC_S_CALLPENDING: # timeout expired
                raise
```

Resolving patch:
diff --git a/source/appModules/outlook.py b/source/appModules/outlook.py
--- a/source/appModules/outlook.py
+++ b/source/appModules/outlook.py
@@ -108,7 +108,10 @@ def _registerCOMWithFocusJuggle(self):
 		self._hasTriedoutlookAppSwitch=True
 		#Make sure NVDA detects and reports focus on the waiting dialog
 		api.processPendingEvents()
-		comtypes.client.PumpEvents(1)
+		try:
+			comtypes.client.PumpEvents(1)
+		except WindowsError:
+			log.debugWarning("Error while pumping com events", exc_info=True)
 		d.Destroy()
 		gui.mainFrame.postPopup()
 
diff --git a/source/appModules/powerpnt.py b/source/appModules/powerpnt.py
--- a/source/appModules/powerpnt.py
+++ b/source/appModules/powerpnt.py
@@ -1257,7 +1257,10 @@ def _registerCOMWithFocusJuggle(self):
 		self.hasTriedPpAppSwitch=True
 		#Make sure NVDA detects and reports focus on the waiting dialog
 		api.processPendingEvents()
-		comtypes.client.PumpEvents(1)
+		try:
+			comtypes.client.PumpEvents(1)
+		except WindowsError:
+			log.debugWarning("Error while pumping com events", exc_info=True)
 		d.Destroy()
 		gui.mainFrame.postPopup()
 


Test patch:
Repository: nvaccess/nvda

Issue:
when opening a java application it is not possible to review the characters typed in a text field

### Steps to reproduce:
Open a java application.
Put the focus in a text field.
Please enter some characters.
Read the typed text with directional arrows.
### Actual behavior:
an error sound is heard and not a character or text is read
### Expected behavior:
the typed text should be read when navigating with the arrows
### System configuration
#### NVDA installed/portable/running from source:
portable
#### NVDA version:
nvda_snapshot_threshold_py3_staging-18066,131ed840.exe
#### Windows version:
10 17763
#### Name and version of other software in use when reproducing the issue:
java application
#### Other information about your system:

### Other questions
#### Does the issue still occur after restarting your PC?
yes
#### Have you tried any other versions of NVDA? If so, please report their behaviors.
yes
I did not notice the problem in alpha verbs.
log:
[java.txt](https://github.com/nvaccess/nvda/files/3399040/java.txt)



Discussion:

Resolving patch:
diff --git a/source/JABHandler.py b/source/JABHandler.py
--- a/source/JABHandler.py
+++ b/source/JABHandler.py
@@ -259,7 +259,7 @@ class AccessibleKeyBindings(Structure):
 	_fixBridgeFunc(BOOL,'getAccessibleTextSelectionInfo',c_long,JOBJECT64,POINTER(AccessibleTextSelectionInfo),errcheck=True)
 	_fixBridgeFunc(BOOL,'getAccessibleTextAttributes',c_long,JOBJECT64,jint,POINTER(AccessibleTextAttributesInfo),errcheck=True)
 	_fixBridgeFunc(BOOL,'getAccessibleTextLineBounds',c_long,JOBJECT64,jint,POINTER(jint),POINTER(jint),errcheck=True)
-	_fixBridgeFunc(BOOL,'getAccessibleTextRange',c_long,JOBJECT64,jint,jint,POINTER(c_wchar),c_short,errcheck=True)
+	_fixBridgeFunc(BOOL,'getAccessibleTextRange',c_long,JOBJECT64,jint,jint,POINTER(c_char),c_short,errcheck=True)
 	_fixBridgeFunc(BOOL,'getCurrentAccessibleValueFromContext',c_long,JOBJECT64,POINTER(c_wchar),c_short,errcheck=True)
 	_fixBridgeFunc(BOOL,'selectTextRange',c_long,JOBJECT64,c_int,c_int,errcheck=True)
 	_fixBridgeFunc(BOOL,'getTextAttributesInRange',c_long,JOBJECT64,c_int,c_int,POINTER(AccessibleTextAttributesInfo),POINTER(c_short),errcheck=True)


Test patch:
Repository: nvaccess/nvda

Issue:
Threshold: "SyntaxError: invalid or missing encoding declaration for 'brailleDisplayDrivers\\handyTech.pyc'"
### Steps to reproduce:
1. Connect a handy tech display using auto detection
2. Disconnect it.

### Actual behavior:
Many logging errors in the log, all leading up to `SyntaxError: invalid or missing encoding declaration for 'brailleDisplayDrivers\\handyTech.pyc'`

### Expected behavior:
NO errors

### System configuration
#### NVDA installed/portable/running from source:
Installed

#### NVDA version:
threshold-18146

#### Windows version:
Windows 10 1903

#### Name and version of other software in use when reproducing the issue:
Handy Tech Active Braille braille display

#### Other information about your system:

### Other questions
#### Does the issue still occur after restarting your PC?
Yes

#### Have you tried any other versions of NVDA? If so, please report their behaviors.
Yes, no errors on alpha.



Discussion:
Mm, manually uninstalling and reinstalling NVDA fixed the problem for me. It turns out that C:\Program Files (x86)\NVDA\brailleDisplayDrivers contained many outdated files. I'd have expected that the installer had cleaned these up, though.

Resolving patch:
diff --git a/source/installer.py b/source/installer.py
--- a/source/installer.py
+++ b/source/installer.py
@@ -205,6 +205,21 @@ def removeOldProgramFiles(destPath):
 	if os.path.isfile(fn):
 		tryRemoveFile(fn)
 
+	# #9960: If compiled python files from older versions aren't removed correctly,
+	# this could cause strange errors when Python tries to create tracebacks
+	# in a newer version of NVDA.
+	for curDestDir,subDirs,files in os.walk(destPath):
+		for f in files:
+			if f.endswith((".pyc", ".pyo")):
+				# This also removes compiled files from system config,
+				# but that is fine.
+				path=os.path.join(curDestDir, f)
+				log.debug(f"Removing old byte compiled python file: {path!r}")
+				try:
+					tryRemoveFile(path)
+				except RetriableFailure:
+					log.warning(f"Couldn't remove file: {path!r}")
+
 uninstallerRegInfo={
 	"DisplayName":versionInfo.name,
 	"DisplayVersion":versionInfo.version,


Test patch:
Repository: nvaccess/nvda

Issue:
Routing cursor don't work
<!--
Please thoroughly read NVDA's wiki article on how to fill in this template, including how to provide the required files.
Issues may be closed if the required information is not present.
https://github.com/nvaccess/nvda/wiki/Github-issue-template-explanation-and-examples
-->

### Steps to reproduce:
* Open a text editor like Notepad.
* Write a text.
* Try to move cursor with routine cursor of Braille Display.

### Actual behavior:
Error sound is play and cursor isn't move.

### Expected behavior:
No error and cursor is move

### System configuration
#### NVDA installed/portable/running from source:
Installed

#### NVDA version:
alpha-18199,af9b85de

#### Windows version:
10.0.18362.239

#### Name and version of other software in use when reproducing the issue:
Notepad

#### Other information about your system:
Use old Papenmeier Braille Display

### Other questions
#### Does the issue still occur after restarting your PC?
Yes

#### Have you tried any other versions of NVDA? If so, please report their behaviors.
Yes, before switch to python 3 this action worked correctly.



Discussion:
Could you please provide a log containing the error?

Oh yes, the part of log containing the error:
"
ERROR - scriptHandler.executeScript (22:30:54.930):
error executing script: <bound method GlobalCommands.script_braille_routeTo of <globalCommands.GlobalCommands object at 0x08970EF0>> with gesture 'route'
Traceback (most recent call last):
  File "scriptHandler.pyc", line 190, in executeScript
  File "globalCommands.pyc", line 2028, in script_braille_routeTo
  File "braille.pyc", line 1770, in routeTo
  File "braille.pyc", line 1387, in routeTo
  File "braille.pyc", line 1059, in routeTo
  File "braille.pyc", line 1026, in getTextInfoForBraillePos
TypeError: list indices must be integers or slices, not float
"
@Oreonan2: thanks for this
Just to make sure, you're using the papenmeier older models display?
@leonardder Yes, exactly

Resolving patch:
diff --git a/source/brailleDisplayDrivers/papenmeier_serial.py b/source/brailleDisplayDrivers/papenmeier_serial.py
--- a/source/brailleDisplayDrivers/papenmeier_serial.py
+++ b/source/brailleDisplayDrivers/papenmeier_serial.py
@@ -182,8 +182,8 @@ def _handleKeyPresses(self): #called by the keycheck timer
 		if(self._dev!=None):
 			data = brl_poll(self._dev)
 			if len(data) == 10 and data[1] == ord(b'K'):
-				pos = data[2] * 256 + data[3]
-				pos = (pos-768)/3
+				pos = (data[2] << 8) + data[3]
+				pos = (pos-768) // 3
 				pressed = data[6]
 				keys = data[8]
 				self._repeatcount = 0


Test patch:
Repository: nvaccess/nvda

Issue:
repetition when focusing a console window
<!--
Please thoroughly read NVDA's wiki article on how to fill in this template, including how to provide the required files.
Issues may be closed if the required information is not present.
https://github.com/nvaccess/nvda/wiki/Github-issue-template-explanation-and-examples
-->

### Steps to reproduce:
open a console window, in my case I open bash
2. open any other windows such a browser. 
3. tab back to your console window.
### Actual behavior:
I hear root@Computer name, window, terminal, selected, terminal selected
### Expected behavior:
hearing only the window name, + "console" to know the type of focused app
### System configuration
core -i7 24 gb ram, ssd drive
#### NVDA installed/portable/running from source:
installed
#### NVDA version:
alpha-18290,7b5cd2d0
#### Windows version:
windows Version 1903 (OS Build 18950.1000)
#### Name and version of other software in use when reproducing the issue:
none
#### Other information about your system:

### Other questions
#### Does the issue still occur after restarting your PC?
yes
#### Have you tried any other versions of NVDA? If so, please report their behaviors.
console work has just landed, so unrelated.


Discussion:
@codeofdusk 

Resolving patch:
diff --git a/source/NVDAObjects/UIA/winConsoleUIA.py b/source/NVDAObjects/UIA/winConsoleUIA.py
--- a/source/NVDAObjects/UIA/winConsoleUIA.py
+++ b/source/NVDAObjects/UIA/winConsoleUIA.py
@@ -235,10 +235,16 @@ class WinConsoleUIA(KeyboardHandlerBasedTypedCharSupport):
 	#: Only process text changes every 30 ms, in case the console is getting
 	#: a lot of text.
 	STABILIZE_DELAY = 0.03
-	_TextInfo = consoleUIATextInfo
 	#: the caret in consoles can take a while to move on Windows 10 1903 and later.
 	_caretMovementTimeoutMultiplier = 1.5
 
+	def _get_TextInfo(self):
+		"""Overriding _get_TextInfo and thus the TextInfo property
+		on NVDAObjects.UIA.UIA
+		consoleUIATextInfo fixes expand/collapse, implements word movement, and
+		bounds review to the visible text."""
+		return consoleUIATextInfo
+
 	def _get_caretMovementDetectionUsesEvents(self):
 		"""Using caret events in consoles sometimes causes the last character of the
 		prompt to be read when quickly deleting text."""


Test patch:
Repository: nvaccess/nvda

Issue:
Obsolete pyd file came from pywin32 after upgrade to alpha may crash nvda
### Steps to reproduce:
1 Upgrade from python 2 based NVDA to python 3 based ones
for example from 2019.1 to alpha-18330,b4db7dca
2 Open NVDA python console type: 
 import win32clipboard
then press enter
### Actual behavior:
An error prompt show up says DLL load error
### Expected behavior:
module not found or loaded correctly if bundled in addon
### System configuration
#### NVDA installed/portable/running from source:
installed/portable

### Other questions
This issue is discovered while updating an addon which uses win32clipboard module to python3.
Even if I bundle win32clipboard.pyd file for python3 in addon. A updated nvda still load the obsolete pyd for python2, thus causing an error prompt.
I suggest removing them along with other pyd file from old pywin32 module when update from an old release since they are obsolete and error prone.
They are "win32ui win32api win32wnet win32clipboard" 



Discussion:
We already delete obsolete pyo and pyc files when updating, so this is a trivial change that is pretty easy to apply.

Resolving patch:
diff --git a/source/installer.py b/source/installer.py
--- a/source/installer.py
+++ b/source/installer.py
@@ -23,7 +23,7 @@
 import easeOfAccess
 import COMRegistrationFixes
 import winKernel
-
+import importlib.machinery
 _wsh=None
 def _getWSH():
 	global _wsh
@@ -210,7 +210,7 @@ def removeOldProgramFiles(destPath):
 	# in a newer version of NVDA.
 	for curDestDir,subDirs,files in os.walk(destPath):
 		for f in files:
-			if f.endswith((".pyc", ".pyo")):
+			if f.endswith((".pyc", ".pyo", ".pyd")) and not f.endswith(importlib.machinery.EXTENSION_SUFFIXES[0]):
 				# This also removes compiled files from system config,
 				# but that is fine.
 				path=os.path.join(curDestDir, f)


Test patch:
Repository: nvaccess/nvda

Issue:
NVDA doesn't announce tabs in IE11
Firstly to say, we are using on project NVDA for checking how accessibility works and found that for our tabs announcing is not working in IE, then I looked into w3 example and found that it is not working also.
### Steps to reproduce: 
1) Open IE 11 and then open: http://www.w3.org/TR/wai-aria-practices/examples/tabs/tabs-1/tabs.html
2) use navigation to Example of Tab menu
3) use navigation between tabs of Example menu
### Actual behavior:
Announce only of tablist and no announce of any tab.

### Expected behavior:
The same announce as in other browsers such as Google Chrome
### System configuration
#### NVDA installed/portable/running from source:
NVDA installed as app on desktop and turned on
#### NVDA version:
2019.1
#### Windows version:
Windows 10
#### Name and version of other software in use when reproducing the issue:

#### Other information about your system:
Version of IE: 11.1746.15063.0
### Other questions
#### Does the issue still occur after restarting your PC?
Yes
#### Have you tried any other versions of NVDA? If so, please report their behaviors.
No


Discussion:
Is this not due to the lack of current development of IE by Microsoft, they 
kind of just left it. Are you saying it used to work before?
 Brian

bglists@blueyonder.co.uk
Sent via blueyonder.
Please address personal E-mail to:-
briang1@blueyonder.co.uk, putting 'Brian Gaff'
in the display name field.
-----  


I couldn't reproduce it with IE 11.0.9600.19301 (32-bit) on Win7x64 and NVDA 2018.1. The names of the tabs are announced correctly in focus mode during switching them by pressing ArrowRight and ArrowLeft.
The obvious  difference is the version of nvda, and windows used between the 
reporter and yourself. I do not know enough about IE version labelling to 
know if it matters on that front.
 It needs another windows 10 IE user to comment I think, but I do stand by 
what I observed earlier about the priority of this problem given such a wide 
choice of better browsers now.
 Brian

bglists@blueyonder.co.uk
Sent via blueyonder.
Please address personal E-mail to:-
briang1@blueyonder.co.uk, putting 'Brian Gaff'
in the display name field.
-----  



Resolving patch:
diff --git a/source/NVDAObjects/IAccessible/MSHTML.py b/source/NVDAObjects/IAccessible/MSHTML.py
--- a/source/NVDAObjects/IAccessible/MSHTML.py
+++ b/source/NVDAObjects/IAccessible/MSHTML.py
@@ -954,7 +954,7 @@ def setFocus(self):
 
 	def _get_table(self):
 		if self.role not in (controlTypes.ROLE_TABLECELL,controlTypes.ROLE_TABLEROW) or not self.HTMLNode:
-			raise NotImplementedError
+			return None
 		HTMLNode=self.HTMLNode
 		while HTMLNode:
 			nodeName=HTMLNode.nodeName
@@ -962,7 +962,7 @@ def _get_table(self):
 				nodeName=nodeName.upper()
 			if nodeName=="TABLE": return MSHTML(HTMLNode=HTMLNode)
 			HTMLNode=HTMLNode.parentNode
-		raise NotImplementedError
+		return None
 
 	def _get_HTMLNodeUniqueNumber(self):
 		if not hasattr(self,'_HTMLNodeUniqueNumber'):


Test patch:
Repository: nvaccess/nvda

Issue:
Add-Ons Manager: Change default Button to "No" for Delete Add-On Confirmation Dialog
When choosing to remove an add-on via the Add-Ons Manager, a warning is displayed; however, the "Yes" button is set as the default. To prevent accidental deletion of add-ons, would it be possible to change the default button that receives focus to "No"? This way, users will need to explicitly move focus to the "Yes" button; implementing this will decrease the likelyhood that add-ons are accidentally deleted.


Discussion:
This is the case with NVDA 2018.1. (NVDA 2019.2 RC1 wasn't tested by me.)

Furthermore I suggest to allocate the ESC key to the button "No". So pressing ESC will activate the button "No" as well.

Resolving patch:
diff --git a/source/gui/addonGui.py b/source/gui/addonGui.py
--- a/source/gui/addonGui.py
+++ b/source/gui/addonGui.py
@@ -297,13 +297,22 @@ def onAddClick(self, evt):
 			self.refreshAddonsList()
 
 	def onRemoveClick(self,evt):
-		index=self.addonsList.GetFirstSelected()
-		if index<0: return
-		# Translators: Presented when attempting to remove the selected add-on.
-		if gui.messageBox(_("Are you sure you wish to remove the selected add-on from NVDA?"),
+		index = self.addonsList.GetFirstSelected()
+		if index < 0:
+			return
+		addon = self.curAddons[index]
+		if gui.messageBox(
+			(_(
+				# Translators: Presented when attempting to remove the selected add-on.
+				# {addon} is replaced with the add-on name.
+				"Are you sure you wish to remove the {addon} add-on from NVDA? "
+				"This cannot be undone."
+			)).format(addon=addon.name),
 			# Translators: Title for message asking if the user really wishes to remove the selected Addon.
-			_("Remove Add-on"), wx.YES_NO|wx.ICON_WARNING) != wx.YES: return
-		addon=self.curAddons[index]
+			_("Remove Add-on"),
+			wx.YES_NO | wx.NO_DEFAULT | wx.ICON_WARNING
+		) != wx.YES:
+			return
 		addon.requestRemove()
 		self.refreshAddonsList(activeIndex=index)
 		self.addonsList.SetFocus()


Test patch:
Repository: nvaccess/nvda

Issue:
Windows 10 1803: Review by character not constrained to current line in Windows Console
<!--
Please thoroughly read NVDA's wiki article on how to fill in this template, including how to provide the required files.
Issues may be closed if the required information is not present.
https://github.com/nvaccess/nvda/wiki/Github-issue-template-explanation-and-examples
-->

### Steps to reproduce:
1. Open Command Prompt.
2. Repeatedly invoke "review previous character" (desktop layout: numpad 1)

### Actual behavior:
The review cursor moves beyond the start of the line under review.

### Expected behavior:
NVDA says "left" and stops at the beginning of the line under review.

### System configuration
#### NVDA installed/portable/running from source:
Temporary copy.

#### NVDA version:
Latest `master` branch.

#### Windows version:
Windows 10 version 1803.

#### Name and version of other software in use when reproducing the issue:
Windows Console (Command Prompt).

#### Other information about your system:

### Other questions
#### Does the issue still occur after restarting your PC?
Yes.

#### Have you tried any other versions of NVDA? If so, please report their behaviors.
No.


Discussion:
Since word review depends on accurate movement by character, it is sometimes unreliable on 1803 especially across lines.

Resolving patch:
diff --git a/source/UIAUtils.py b/source/UIAUtils.py
--- a/source/UIAUtils.py
+++ b/source/UIAUtils.py
@@ -239,4 +239,4 @@ def shouldUseUIAConsole(setting=None):
 	# ignore it.
 	# It does not implement caret/selection, and probably has no
 	# new text events.
-	return isWin10(1803)
+	return isWin10(1809)


Test patch:
Repository: nvaccess/nvda

Issue:
Python 3: Word navigation fails on objects with unicode cahracters in it
## Steps to reproduce:
1. In Windows Explorer, create a new folder
2. Name it `Hello 👌 hello`
3. With numpad 4/6 (laptop: NVDA+Control+legt/rightArrow), navigate word by word in the object.

### Actual behavior:
Moving to the right is stuck on the emoji

### Expected behavior:
Word nav allows you to navigate through the complete word.



Discussion:

Resolving patch:
diff --git a/source/textInfos/offsets.py b/source/textInfos/offsets.py
--- a/source/textInfos/offsets.py
+++ b/source/textInfos/offsets.py
@@ -318,24 +318,36 @@ def _getWordOffsets(self,offset):
 		if self.encoding not in (textUtils.WCHAR_ENCODING, None, "utf_32_le", locale.getlocale()[1]):
 			raise NotImplementedError
 		lineStart, lineEnd = self._getLineOffsets(offset)
-		relOffset = offset - lineStart
 		lineText = self._getTextRange(lineStart,lineEnd)
 		# Convert NULL and non-breaking space to space to make sure that words will break on them
 		lineText = lineText.translate({0:u' ',0xa0:u' '})
+		relOffset = offset - lineStart
 		if self.useUniscribe:
 			relStart=ctypes.c_int()
 			relEnd=ctypes.c_int()
 			# uniscribe does some strange things when you give it a string  with not more than two alphanumeric chars in a row.
 			# Inject two alphanumeric characters at the end to fix this 
-			lineText += "xx"
+			uniscribeLineText = lineText + "xx"
 			# We can't rely on len(lineText) to calculate the length of the line.
-			lineLength = (lineEnd - lineStart) + 2
-			if NVDAHelper.localLib.calculateWordOffsets(lineText, lineLength, relOffset, ctypes.byref(relStart), ctypes.byref(relEnd)):
+			if self.encoding != textUtils.WCHAR_ENCODING:
+				# We need to convert the str based line offsets to wide string offsets.
+				offsetConverter = textUtils.WideStringOffsetConverter(lineText)
+				lineLength = offsetConverter.wideStringLength
+				relOffset = offsetConverter.strToWideOffsets(relOffset, relOffset)[0]
+			else:
+				lineLength = (lineEnd - lineStart)
+			uniscribeLineLength = lineLength + 2
+			if NVDAHelper.localLib.calculateWordOffsets(
+				uniscribeLineText,
+				uniscribeLineLength,
+				relOffset,
+				ctypes.byref(relStart),
+				ctypes.byref(relEnd)
+			):
 				relStart = relStart.value
 				relEnd = relEnd.value
 				if self.encoding != textUtils.WCHAR_ENCODING:
 					# We need to convert the uniscribe based offsets to str offsets.
-					offsetConverter = textUtils.WideStringOffsetConverter(lineText)
 					relStart, relEnd = offsetConverter.wideToStrOffsets(relStart, relEnd)
 				return (relStart + lineStart , relEnd + lineStart)
 		#Fall back to the older word offsets detection that only breaks on non alphanumeric


Test patch: