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.
| # 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.
Please split this line while at it
| #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.
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? |
|
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