New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python 3: zip function -> list(zip), itertools.izip -> zip() #9729
Python 3: zip function -> list(zip), itertools.izip -> zip() #9729
Conversation
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.
@@ -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]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please split this line while at it
source/languageHandler.py
Outdated
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this comment is necessary. Furthermore, it contains a typo.
…ndler, pslit lines in mozilla text iA2 objects.
Hi, done – hopefully the split lines are what you are looking for. Thanks.
|
@LeonarddeR are you still waiting for changes on this, or are you going to approve? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, go ahead.
After merging this, setup.py failed as it found a syntax error in source\NVDAObjects\IAccessible\ia2TextMozilla.py, introduced by this pr. Due to a for loop being split across two lines. |
That makes sense. I'll refrain from review comments requesting for line
splitting.
|
Hi,
Discovered through a series of failing unit tests:
Link to issue number:
None
Summary of the issue:
Python 2 and 3 zip functions have different behaviors: returns a list in Python 2 vs an iterator in Python 3.
Description of how this pull request fixes the issue:
Changed instances of zip() function call to list(zip), as well as rename itertools.izip to zip().
Steps:
Testing performed:
Tested in Python 2 and 3 interpreters.
Known issues with pull request:
None
Change log entry:
None