From 16760df55c30f382c6a7aca4d95c1d0f8ef39d21 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Wed, 12 Jun 2019 14:57:17 -0700 Subject: [PATCH 1/5] Language list/Python 3: wrap zip function call inside a list call. Behavior of zip() functoin has changed - returning a list in Python 2 versus being an iterator in Python 3. Because language handler/language list uses old zip function behavior, wrap this inside a list call. --- source/languageHandler.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/languageHandler.py b/source/languageHandler.py index 10ec72ee191..ba1fff29463 100644 --- a/source/languageHandler.py +++ b/source/languageHandler.py @@ -108,7 +108,9 @@ def getAvailableLanguages(presentational=False): displayNames.append("%s, %s"%(desc,entry) if desc else entry) #Prepare a zipped view of language codes and descriptions. # #7284: especially for sorting by description. - langs = zip(locales,displayNames) + # #7105 (Py3 review required): Python 2 list 0> Python 3 iterator. + # Thus wrap this inside a list call. + langs = list(zip(locales,displayNames)) if presentational: langs.sort(key=lambda lang: lang[1]) #include a 'user default, windows' language, which just represents the default language for this user account From cac359ecc60b782b99d44578bb56760fb7e9e62c Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Wed, 12 Jun 2019 14:58:03 -0700 Subject: [PATCH 2/5] IAccessible/IA2mozilla: itertools.izip -> zip, remove itertools import. --- source/NVDAObjects/IAccessible/ia2TextMozilla.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/NVDAObjects/IAccessible/ia2TextMozilla.py b/source/NVDAObjects/IAccessible/ia2TextMozilla.py index 77ab540ae9c..a8545b8f9ea 100644 --- a/source/NVDAObjects/IAccessible/ia2TextMozilla.py +++ b/source/NVDAObjects/IAccessible/ia2TextMozilla.py @@ -8,7 +8,6 @@ This is now used by other applications as well. """ -import itertools from comtypes import COMError import winUser import textInfos @@ -628,7 +627,7 @@ def compareEndPoints(self, other, which): otherAncs = self._getAncestors(otherTi, otherObj) # Find the first common ancestor. maxAncIndex = min(len(selfAncs), len(otherAncs)) - 1 - for (selfAncTi, selfAncObj), (otherAncTi, otherAncObj) in itertools.izip(selfAncs[maxAncIndex::-1], otherAncs[maxAncIndex::-1]): + for (selfAncTi, selfAncObj), (otherAncTi, otherAncObj) in zip(selfAncs[maxAncIndex::-1], otherAncs[maxAncIndex::-1]): if selfAncObj == otherAncObj: break else: From 7f211c8309b72eb02a7e67b407cd9e5163939ef9 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Wed, 12 Jun 2019 14:58:22 -0700 Subject: [PATCH 3/5] Braille: itertools.izip -> zip function. --- source/braille.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/braille.py b/source/braille.py index e5e154c0c53..964239a8681 100644 --- a/source/braille.py +++ b/source/braille.py @@ -1434,7 +1434,7 @@ def getFocusContextRegions(obj, oldFocusRegions=None): # We only want the ancestors of the buffer's root NVDAObject. if obj != api.getFocusObject(): # Search backwards through the focus ancestors to find the index of obj. - for index, ancestor in itertools.izip(range(len(ancestors) - 1, 0, -1), reversed(ancestors)): + for index, ancestor in zip(range(len(ancestors) - 1, 0, -1), reversed(ancestors)): if obj == ancestor: ancestorsEnd = index break @@ -1446,7 +1446,7 @@ def getFocusContextRegions(obj, oldFocusRegions=None): # Also, we don't ever want to fetch ancestor 0 (the desktop). newAncestorsStart = max(min(_cachedFocusAncestorsEnd, ancestorsEnd), 1) # Search backwards through the old regions to find the last common region. - for index, region in itertools.izip(range(len(oldFocusRegions) - 1, -1, -1), reversed(oldFocusRegions)): + for index, region in zip(range(len(oldFocusRegions) - 1, -1, -1), reversed(oldFocusRegions)): ancestorIndex = getattr(region, "_focusAncestorIndex", None) if ancestorIndex is None: continue From c1cebc704ffc08d2643d9e479615206052a39ae1 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Wed, 12 Jun 2019 15:38:04 -0700 Subject: [PATCH 4/5] Language handler: remove extraneous whitespace --- source/languageHandler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/languageHandler.py b/source/languageHandler.py index ba1fff29463..070635b9c03 100644 --- a/source/languageHandler.py +++ b/source/languageHandler.py @@ -108,8 +108,8 @@ def getAvailableLanguages(presentational=False): displayNames.append("%s, %s"%(desc,entry) if desc else entry) #Prepare a zipped view of language codes and descriptions. # #7284: especially for sorting by description. - # #7105 (Py3 review required): Python 2 list 0> Python 3 iterator. - # Thus wrap this inside a list call. + # #7105 (Py3 review required): Python 2 list 0> Python 3 iterator. + # Thus wrap this inside a list call. langs = list(zip(locales,displayNames)) if presentational: langs.sort(key=lambda lang: lang[1]) From 440da5340e78d437888ea6fccaa8f83d9332561b Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Wed, 12 Jun 2019 21:06:46 -0700 Subject: [PATCH 5/5] Izip to zip (address review actions): simplify comment in language handler, pslit lines in mozilla text iA2 objects. --- source/NVDAObjects/IAccessible/ia2TextMozilla.py | 3 ++- source/languageHandler.py | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/NVDAObjects/IAccessible/ia2TextMozilla.py b/source/NVDAObjects/IAccessible/ia2TextMozilla.py index a8545b8f9ea..bed27c50a86 100644 --- a/source/NVDAObjects/IAccessible/ia2TextMozilla.py +++ b/source/NVDAObjects/IAccessible/ia2TextMozilla.py @@ -627,7 +627,8 @@ def compareEndPoints(self, other, which): otherAncs = self._getAncestors(otherTi, otherObj) # Find the first common ancestor. maxAncIndex = min(len(selfAncs), len(otherAncs)) - 1 - for (selfAncTi, selfAncObj), (otherAncTi, otherAncObj) in zip(selfAncs[maxAncIndex::-1], otherAncs[maxAncIndex::-1]): + for (selfAncTi, selfAncObj), (otherAncTi, otherAncObj) in + zip(selfAncs[maxAncIndex::-1], otherAncs[maxAncIndex::-1]): if selfAncObj == otherAncObj: break else: diff --git a/source/languageHandler.py b/source/languageHandler.py index 070635b9c03..dee18d31c66 100644 --- a/source/languageHandler.py +++ b/source/languageHandler.py @@ -108,8 +108,7 @@ def getAvailableLanguages(presentational=False): displayNames.append("%s, %s"%(desc,entry) if desc else entry) #Prepare a zipped view of language codes and descriptions. # #7284: especially for sorting by description. - # #7105 (Py3 review required): Python 2 list 0> Python 3 iterator. - # Thus wrap this inside a list call. + # Python 3: zip function changed from returning a list to an iterator, thus wrap this inside a list call. langs = list(zip(locales,displayNames)) if presentational: langs.sort(key=lambda lang: lang[1])