We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
NVDA doesn't read anything on iTunes
Today I woke up and NVDA was no longer reading anything on iTunes.  After investigating I figured that iTunes was updated to version 12.9.0.167 from the Microsoft Store overnight, so suspecting it might be an issue with iTunes I tried Narrator which worked just fine.

I'm running Microsoft Windows 10 Home version 10.0.17134 Build 17134 with NVDA 2018.2.1, and after analyzing the [log](https://github.com/nvaccess/nvda/files/2379550/nvda.log) I found that there were exceptions every time I tried to interact with iTunes.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `source/appModules/itunes.py`
Content:
```
1 #appModules/itunes.py
2 #A part of NonVisual Desktop Access (NVDA)
3 #This file is covered by the GNU General Public License.
4 #See the file COPYING for more details.
5 #Copyright (C) 2009-2015 NV Access Limited
6 
7 """App module for iTunes
8 """
9 
10 import appModuleHandler
11 from comtypes import COMError
12 import controlTypes
13 import oleacc
14 import winUser
15 import speech
16 import treeInterceptorHandler
17 import api
18 import eventHandler
19 import NVDAObjects.IAccessible
20 from NVDAObjects.IAccessible import webKit
21 
22 class AppModule(appModuleHandler.AppModule):
23 
24 	def event_NVDAObject_init(self,obj):
25 		if isinstance(obj,NVDAObjects.IAccessible.IAccessible):
26 			if obj.windowClassName=="WebViewWindowClass":
27 				if obj.IAccessibleRole==oleacc.ROLE_SYSTEM_WINDOW:
28 					#Disable a safety mechonism in our IAccessible support as in iTunes it causes an infinit ancestry.
29 					obj.parentUsesSuperOnWindowRootIAccessible=False
30 				else:
31 					obj.hasEncodedAccDescription=True
32 			elif obj.role==controlTypes.ROLE_BUTTON:
33 				# iTunes seems to put some controls inside a button.
34 				# Don't report this weirdness to the user.
35 				obj.isPresentableFocusAncestor=False
36 			elif obj.windowClassName=="iTunesWebViewControl" and obj.role==controlTypes.ROLE_DOCUMENT:
37 				# This wrapper should never be seen by the user.
38 				obj.shouldAllowIAccessibleFocusEvent = False
39 				obj.presentationType = obj.presType_layout
40 
41 	def chooseNVDAObjectOverlayClasses(self, obj, clsList):
42 		windowClassName=obj.windowClassName
43 		role=obj.role
44 		if windowClassName in ('iTunesList','iTunesSources','iTunesTrackList') and role in (controlTypes.ROLE_LISTITEM,controlTypes.ROLE_TREEVIEWITEM):
45 			clsList.insert(0, ITunesItem)
46 		elif webKit.Document in clsList:
47 			clsList.insert(0, WebKitDocument)
48 		elif windowClassName=="iTunes" and obj.IAccessibleRole==oleacc.ROLE_SYSTEM_CLIENT:
49 			clsList.insert(0, TopLevelClient)
50 
51 class ITunesItem(NVDAObjects.IAccessible.IAccessible):
52 	"""Retreaves position information encoded in the accDescription"""
53 
54 	hasEncodedAccDescription=True
55 	value = None
56 
57 	def _get_next(self):
58 		next=super(ITunesItem,self).next
59 		if next:
60 			return next
61 		try:
62 			parentChildCount=self.IAccessibleObject.accChildCount
63 		except COMError:
64 			parentChildCount=0
65 		if self.IAccessibleChildID>0 and self.IAccessibleChildID<parentChildCount:
66 			return NVDAObjects.IAccessible.IAccessible(windowHandle=self.windowHandle,IAccessibleObject=self.IAccessibleObject,IAccessibleChildID=self.IAccessibleChildID+1)
67 		return None
68 
69 	def _get_previous(self):
70 		previous=super(ITunesItem,self).previous
71 		if not previous and self.IAccessibleChildID>1:
72 			previous=NVDAObjects.IAccessible.IAccessible(windowHandle=self.windowHandle,IAccessibleObject=self.IAccessibleObject,IAccessibleChildID=self.IAccessibleChildID-1)
73 		return previous
74 
75 	def _get_shouldAllowIAccessibleFocusEvent(self):
76 		# These items can fire spurious focus events; e.g. when tabbing out of the Music list.
77 		# The list reports that it's focused even when it isn't.
78 		# Thankfully, the list items don't.
79 		return self.hasFocus
80 
81 class WebKitDocument(webKit.Document):
82 
83 	def event_stateChange(self):
84 		# iTunes has indicated that a page has died and been replaced by a new one.
85 		# #5191: This is actually fired on the "iTunesWebViewControl" parent,
86 		# but AccessibleObjectFromEvent on this window returns the WebKit document as of iTunes 12.
87 		focus = api.getFocusObject()
88 		if self.windowHandle != focus.windowHandle:
89 			return
90 		# The new page has the same event params, so we must bypass NVDA's IAccessible caching.
91 		obj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(focus.windowHandle, winUser.OBJID_CLIENT, 0)
92 		if not obj:
93 			return
94 		if focus.treeInterceptor:
95 			speech.cancelSpeech()
96 			treeInterceptorHandler.killTreeInterceptor(focus.treeInterceptor)
97 		eventHandler.queueEvent("gainFocus",obj)
98 
99 class TopLevelClient(NVDAObjects.IAccessible.IAccessible):
100 
101 	def _isEqual(self, other):
102 		# The location seems to be reported differently depending on how you get to this object.
103 		# This causes the focus ancestry to change when it really hasn't,
104 		# which in turn causes spurious reporting.
105 		if self.IAccessibleIdentity == other.IAccessibleIdentity:
106 			return True
107 		return super(TopLevelClient, self)._isEqual(other)
108
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/source/appModules/itunes.py b/source/appModules/itunes.py
--- a/source/appModules/itunes.py
+++ b/source/appModules/itunes.py
@@ -2,7 +2,7 @@
 #A part of NonVisual Desktop Access (NVDA)
 #This file is covered by the GNU General Public License.
 #See the file COPYING for more details.
-#Copyright (C) 2009-2015 NV Access Limited
+#Copyright (C) 2009-2018 NV Access Limited, Leonard de Ruijter
 
 """App module for iTunes
 """
@@ -17,6 +17,7 @@
 import api
 import eventHandler
 import NVDAObjects.IAccessible
+import NVDAObjects.UIA
 from NVDAObjects.IAccessible import webKit
 
 class AppModule(appModuleHandler.AppModule):
@@ -39,6 +40,10 @@
 				obj.presentationType = obj.presType_layout
 
 	def chooseNVDAObjectOverlayClasses(self, obj, clsList):
+		if isinstance(obj,NVDAObjects.UIA.UIA):
+			# iTunes 12.9 implements UIA for many controls.
+			# Just leave them untouched for now.
+			return
 		windowClassName=obj.windowClassName
 		role=obj.role
 		if windowClassName in ('iTunesList','iTunesSources','iTunesTrackList') and role in (controlTypes.ROLE_LISTITEM,controlTypes.ROLE_TREEVIEWITEM):

{"golden_diff": "diff --git a/source/appModules/itunes.py b/source/appModules/itunes.py\n--- a/source/appModules/itunes.py\n+++ b/source/appModules/itunes.py\n@@ -2,7 +2,7 @@\n #A part of NonVisual Desktop Access (NVDA)\r\n #This file is covered by the GNU General Public License.\r\n #See the file COPYING for more details.\r\n-#Copyright (C) 2009-2015 NV Access Limited\r\n+#Copyright (C) 2009-2018 NV Access Limited, Leonard de Ruijter\r\n \r\n \"\"\"App module for iTunes\r\n \"\"\"\r\n@@ -17,6 +17,7 @@\n import api\r\n import eventHandler\r\n import NVDAObjects.IAccessible\r\n+import NVDAObjects.UIA\r\n from NVDAObjects.IAccessible import webKit\r\n \r\n class AppModule(appModuleHandler.AppModule):\r\n@@ -39,6 +40,10 @@\n \t\t\t\tobj.presentationType = obj.presType_layout\r\n \r\n \tdef chooseNVDAObjectOverlayClasses(self, obj, clsList):\r\n+\t\tif isinstance(obj,NVDAObjects.UIA.UIA):\r\n+\t\t\t# iTunes 12.9 implements UIA for many controls.\r\n+\t\t\t# Just leave them untouched for now.\r\n+\t\t\treturn\r\n \t\twindowClassName=obj.windowClassName\r\n \t\trole=obj.role\r\n \t\tif windowClassName in ('iTunesList','iTunesSources','iTunesTrackList') and role in (controlTypes.ROLE_LISTITEM,controlTypes.ROLE_TREEVIEWITEM):\n", "issue": "NVDA doesn't read anything on iTunes\nToday I woke up and NVDA was no longer reading anything on iTunes.  After investigating I figured that iTunes was updated to version 12.9.0.167 from the Microsoft Store overnight, so suspecting it might be an issue with iTunes I tried Narrator which worked just fine.\r\n\r\nI'm running Microsoft Windows 10 Home version 10.0.17134 Build 17134 with NVDA 2018.2.1, and after analyzing the [log](https://github.com/nvaccess/nvda/files/2379550/nvda.log) I found that there were exceptions every time I tried to interact with iTunes.\n", "before_files": [{"content": "#appModules/itunes.py\r\n#A part of NonVisual Desktop Access (NVDA)\r\n#This file is covered by the GNU General Public License.\r\n#See the file COPYING for more details.\r\n#Copyright (C) 2009-2015 NV Access Limited\r\n\r\n\"\"\"App module for iTunes\r\n\"\"\"\r\n\r\nimport appModuleHandler\r\nfrom comtypes import COMError\r\nimport controlTypes\r\nimport oleacc\r\nimport winUser\r\nimport speech\r\nimport treeInterceptorHandler\r\nimport api\r\nimport eventHandler\r\nimport NVDAObjects.IAccessible\r\nfrom NVDAObjects.IAccessible import webKit\r\n\r\nclass AppModule(appModuleHandler.AppModule):\r\n\r\n\tdef event_NVDAObject_init(self,obj):\r\n\t\tif isinstance(obj,NVDAObjects.IAccessible.IAccessible):\r\n\t\t\tif obj.windowClassName==\"WebViewWindowClass\":\r\n\t\t\t\tif obj.IAccessibleRole==oleacc.ROLE_SYSTEM_WINDOW:\r\n\t\t\t\t\t#Disable a safety mechonism in our IAccessible support as in iTunes it causes an infinit ancestry.\r\n\t\t\t\t\tobj.parentUsesSuperOnWindowRootIAccessible=False\r\n\t\t\t\telse:\r\n\t\t\t\t\tobj.hasEncodedAccDescription=True\r\n\t\t\telif obj.role==controlTypes.ROLE_BUTTON:\r\n\t\t\t\t# iTunes seems to put some controls inside a button.\r\n\t\t\t\t# Don't report this weirdness to the user.\r\n\t\t\t\tobj.isPresentableFocusAncestor=False\r\n\t\t\telif obj.windowClassName==\"iTunesWebViewControl\" and obj.role==controlTypes.ROLE_DOCUMENT:\r\n\t\t\t\t# This wrapper should never be seen by the user.\r\n\t\t\t\tobj.shouldAllowIAccessibleFocusEvent = False\r\n\t\t\t\tobj.presentationType = obj.presType_layout\r\n\r\n\tdef chooseNVDAObjectOverlayClasses(self, obj, clsList):\r\n\t\twindowClassName=obj.windowClassName\r\n\t\trole=obj.role\r\n\t\tif windowClassName in ('iTunesList','iTunesSources','iTunesTrackList') and role in (controlTypes.ROLE_LISTITEM,controlTypes.ROLE_TREEVIEWITEM):\r\n\t\t\tclsList.insert(0, ITunesItem)\r\n\t\telif webKit.Document in clsList:\r\n\t\t\tclsList.insert(0, WebKitDocument)\r\n\t\telif windowClassName==\"iTunes\" and obj.IAccessibleRole==oleacc.ROLE_SYSTEM_CLIENT:\r\n\t\t\tclsList.insert(0, TopLevelClient)\r\n\r\nclass ITunesItem(NVDAObjects.IAccessible.IAccessible):\r\n\t\"\"\"Retreaves position information encoded in the accDescription\"\"\"\r\n\r\n\thasEncodedAccDescription=True\r\n\tvalue = None\r\n\r\n\tdef _get_next(self):\r\n\t\tnext=super(ITunesItem,self).next\r\n\t\tif next:\r\n\t\t\treturn next\r\n\t\ttry:\r\n\t\t\tparentChildCount=self.IAccessibleObject.accChildCount\r\n\t\texcept COMError:\r\n\t\t\tparentChildCount=0\r\n\t\tif self.IAccessibleChildID>0 and self.IAccessibleChildID<parentChildCount:\r\n\t\t\treturn NVDAObjects.IAccessible.IAccessible(windowHandle=self.windowHandle,IAccessibleObject=self.IAccessibleObject,IAccessibleChildID=self.IAccessibleChildID+1)\r\n\t\treturn None\r\n\r\n\tdef _get_previous(self):\r\n\t\tprevious=super(ITunesItem,self).previous\r\n\t\tif not previous and self.IAccessibleChildID>1:\r\n\t\t\tprevious=NVDAObjects.IAccessible.IAccessible(windowHandle=self.windowHandle,IAccessibleObject=self.IAccessibleObject,IAccessibleChildID=self.IAccessibleChildID-1)\r\n\t\treturn previous\r\n\r\n\tdef _get_shouldAllowIAccessibleFocusEvent(self):\r\n\t\t# These items can fire spurious focus events; e.g. when tabbing out of the Music list.\r\n\t\t# The list reports that it's focused even when it isn't.\r\n\t\t# Thankfully, the list items don't.\r\n\t\treturn self.hasFocus\r\n\r\nclass WebKitDocument(webKit.Document):\r\n\r\n\tdef event_stateChange(self):\r\n\t\t# iTunes has indicated that a page has died and been replaced by a new one.\r\n\t\t# #5191: This is actually fired on the \"iTunesWebViewControl\" parent,\r\n\t\t# but AccessibleObjectFromEvent on this window returns the WebKit document as of iTunes 12.\r\n\t\tfocus = api.getFocusObject()\r\n\t\tif self.windowHandle != focus.windowHandle:\r\n\t\t\treturn\r\n\t\t# The new page has the same event params, so we must bypass NVDA's IAccessible caching.\r\n\t\tobj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(focus.windowHandle, winUser.OBJID_CLIENT, 0)\r\n\t\tif not obj:\r\n\t\t\treturn\r\n\t\tif focus.treeInterceptor:\r\n\t\t\tspeech.cancelSpeech()\r\n\t\t\ttreeInterceptorHandler.killTreeInterceptor(focus.treeInterceptor)\r\n\t\teventHandler.queueEvent(\"gainFocus\",obj)\r\n\r\nclass TopLevelClient(NVDAObjects.IAccessible.IAccessible):\r\n\r\n\tdef _isEqual(self, other):\r\n\t\t# The location seems to be reported differently depending on how you get to this object.\r\n\t\t# This causes the focus ancestry to change when it really hasn't,\r\n\t\t# which in turn causes spurious reporting.\r\n\t\tif self.IAccessibleIdentity == other.IAccessibleIdentity:\r\n\t\t\treturn True\r\n\t\treturn super(TopLevelClient, self)._isEqual(other)\r\n", "path": "source/appModules/itunes.py"}], "after_files": [{"content": "#appModules/itunes.py\r\n#A part of NonVisual Desktop Access (NVDA)\r\n#This file is covered by the GNU General Public License.\r\n#See the file COPYING for more details.\r\n#Copyright (C) 2009-2018 NV Access Limited, Leonard de Ruijter\r\n\r\n\"\"\"App module for iTunes\r\n\"\"\"\r\n\r\nimport appModuleHandler\r\nfrom comtypes import COMError\r\nimport controlTypes\r\nimport oleacc\r\nimport winUser\r\nimport speech\r\nimport treeInterceptorHandler\r\nimport api\r\nimport eventHandler\r\nimport NVDAObjects.IAccessible\r\nimport NVDAObjects.UIA\r\nfrom NVDAObjects.IAccessible import webKit\r\n\r\nclass AppModule(appModuleHandler.AppModule):\r\n\r\n\tdef event_NVDAObject_init(self,obj):\r\n\t\tif isinstance(obj,NVDAObjects.IAccessible.IAccessible):\r\n\t\t\tif obj.windowClassName==\"WebViewWindowClass\":\r\n\t\t\t\tif obj.IAccessibleRole==oleacc.ROLE_SYSTEM_WINDOW:\r\n\t\t\t\t\t#Disable a safety mechonism in our IAccessible support as in iTunes it causes an infinit ancestry.\r\n\t\t\t\t\tobj.parentUsesSuperOnWindowRootIAccessible=False\r\n\t\t\t\telse:\r\n\t\t\t\t\tobj.hasEncodedAccDescription=True\r\n\t\t\telif obj.role==controlTypes.ROLE_BUTTON:\r\n\t\t\t\t# iTunes seems to put some controls inside a button.\r\n\t\t\t\t# Don't report this weirdness to the user.\r\n\t\t\t\tobj.isPresentableFocusAncestor=False\r\n\t\t\telif obj.windowClassName==\"iTunesWebViewControl\" and obj.role==controlTypes.ROLE_DOCUMENT:\r\n\t\t\t\t# This wrapper should never be seen by the user.\r\n\t\t\t\tobj.shouldAllowIAccessibleFocusEvent = False\r\n\t\t\t\tobj.presentationType = obj.presType_layout\r\n\r\n\tdef chooseNVDAObjectOverlayClasses(self, obj, clsList):\r\n\t\tif isinstance(obj,NVDAObjects.UIA.UIA):\r\n\t\t\t# iTunes 12.9 implements UIA for many controls.\r\n\t\t\t# Just leave them untouched for now.\r\n\t\t\treturn\r\n\t\twindowClassName=obj.windowClassName\r\n\t\trole=obj.role\r\n\t\tif windowClassName in ('iTunesList','iTunesSources','iTunesTrackList') and role in (controlTypes.ROLE_LISTITEM,controlTypes.ROLE_TREEVIEWITEM):\r\n\t\t\tclsList.insert(0, ITunesItem)\r\n\t\telif webKit.Document in clsList:\r\n\t\t\tclsList.insert(0, WebKitDocument)\r\n\t\telif windowClassName==\"iTunes\" and obj.IAccessibleRole==oleacc.ROLE_SYSTEM_CLIENT:\r\n\t\t\tclsList.insert(0, TopLevelClient)\r\n\r\nclass ITunesItem(NVDAObjects.IAccessible.IAccessible):\r\n\t\"\"\"Retreaves position information encoded in the accDescription\"\"\"\r\n\r\n\thasEncodedAccDescription=True\r\n\tvalue = None\r\n\r\n\tdef _get_next(self):\r\n\t\tnext=super(ITunesItem,self).next\r\n\t\tif next:\r\n\t\t\treturn next\r\n\t\ttry:\r\n\t\t\tparentChildCount=self.IAccessibleObject.accChildCount\r\n\t\texcept COMError:\r\n\t\t\tparentChildCount=0\r\n\t\tif self.IAccessibleChildID>0 and self.IAccessibleChildID<parentChildCount:\r\n\t\t\treturn NVDAObjects.IAccessible.IAccessible(windowHandle=self.windowHandle,IAccessibleObject=self.IAccessibleObject,IAccessibleChildID=self.IAccessibleChildID+1)\r\n\t\treturn None\r\n\r\n\tdef _get_previous(self):\r\n\t\tprevious=super(ITunesItem,self).previous\r\n\t\tif not previous and self.IAccessibleChildID>1:\r\n\t\t\tprevious=NVDAObjects.IAccessible.IAccessible(windowHandle=self.windowHandle,IAccessibleObject=self.IAccessibleObject,IAccessibleChildID=self.IAccessibleChildID-1)\r\n\t\treturn previous\r\n\r\n\tdef _get_shouldAllowIAccessibleFocusEvent(self):\r\n\t\t# These items can fire spurious focus events; e.g. when tabbing out of the Music list.\r\n\t\t# The list reports that it's focused even when it isn't.\r\n\t\t# Thankfully, the list items don't.\r\n\t\treturn self.hasFocus\r\n\r\nclass WebKitDocument(webKit.Document):\r\n\r\n\tdef event_stateChange(self):\r\n\t\t# iTunes has indicated that a page has died and been replaced by a new one.\r\n\t\t# #5191: This is actually fired on the \"iTunesWebViewControl\" parent,\r\n\t\t# but AccessibleObjectFromEvent on this window returns the WebKit document as of iTunes 12.\r\n\t\tfocus = api.getFocusObject()\r\n\t\tif self.windowHandle != focus.windowHandle:\r\n\t\t\treturn\r\n\t\t# The new page has the same event params, so we must bypass NVDA's IAccessible caching.\r\n\t\tobj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(focus.windowHandle, winUser.OBJID_CLIENT, 0)\r\n\t\tif not obj:\r\n\t\t\treturn\r\n\t\tif focus.treeInterceptor:\r\n\t\t\tspeech.cancelSpeech()\r\n\t\t\ttreeInterceptorHandler.killTreeInterceptor(focus.treeInterceptor)\r\n\t\teventHandler.queueEvent(\"gainFocus\",obj)\r\n\r\nclass TopLevelClient(NVDAObjects.IAccessible.IAccessible):\r\n\r\n\tdef _isEqual(self, other):\r\n\t\t# The location seems to be reported differently depending on how you get to this object.\r\n\t\t# This causes the focus ancestry to change when it really hasn't,\r\n\t\t# which in turn causes spurious reporting.\r\n\t\tif self.IAccessibleIdentity == other.IAccessibleIdentity:\r\n\t\t\treturn True\r\n\t\treturn super(TopLevelClient, self)._isEqual(other)\r\n", "path": "source/appModules/itunes.py"}]}