Skip to content

Python 3: dictionary iteration/list methods made compatible with Python 3 - #9671

Merged
michaelDCurran merged 24 commits into
nvaccess:threshold_py3_stagingfrom
josephsl:py3dictIterMethods
Jun 8, 2019
Merged

Python 3: dictionary iteration/list methods made compatible with Python 3#9671
michaelDCurran merged 24 commits into
nvaccess:threshold_py3_stagingfrom
josephsl:py3dictIterMethods

Conversation

@josephsl

@josephsl josephsl commented Jun 5, 2019

Copy link
Copy Markdown
Contributor

Link to issue number:

Fixes #9067

Summary of the issue:

Python 2 and 3 have different expectations ofr dictionary iteration, including dict.iteritems/iterkeys/itervalues vs dict.items/keys/values and related functionality.

Description of how this pull request fixes the issue:

The following changes were made:

  • dict.items/keys/values originally written in Python 2: wrapped inside a list call with justification comments.
  • dict.iteritems/iterkeys/itervalues: changed to dict.items/keys/values, with some of them accompanied by an explanatory note.

Testing performed:

Tested with Python 3 (the interpreter and NVDA source code), along with testing equivalent functionality in Python 2 (interpreter and Python Console).

Known issues with pull request:

There might be some more dictionary iteration methods that might be present.

Change log entry:

None

Additional notes:

For dict.iterkeys -> dict.keys, Python 3 may ask us to just use "for something in dict". This should be deferred until Python 3 transition is complete.

Thanks.

josephsl added 24 commits June 3, 2019 17:37
…all. Re nvaccess#9067.

Modules such as UIA handler, settings dialogs and others use dict.items/keys/values. This means in Python 2, it returns a list, whereas it returns an iterator in Python 3. Therefore wrap these inside a list call to preserve semantics (also include notes for some of these).
@josephsl
josephsl requested a review from feerrenrut June 5, 2019 03:05
@josephsl josephsl changed the title Python 3: dictionary iteration/list methods made compatbiel with Python 3 Python 3: dictionary iteration/list methods made compatible with Python 3 Jun 5, 2019
@josephsl

josephsl commented Jun 5, 2019

Copy link
Copy Markdown
Contributor Author

Hi,

Commit count: this is because it is divided into two major themes: saving existing dict.items/keys/values, and then modifying iter* methods based on modules.

Thanks.

@LeonarddeR

LeonarddeR commented Jun 5, 2019 via email

Copy link
Copy Markdown
Collaborator

@josephsl

josephsl commented Jun 5, 2019 via email

Copy link
Copy Markdown
Contributor Author

@LeonarddeR

LeonarddeR commented Jun 5, 2019 via email

Copy link
Copy Markdown
Collaborator

@josephsl

josephsl commented Jun 5, 2019 via email

Copy link
Copy Markdown
Contributor Author

@michaelDCurran
michaelDCurran changed the base branch from threshold to threshold_py3_staging June 8, 2019 03:53
@michaelDCurran
michaelDCurran merged commit 1d43a4e into nvaccess:threshold_py3_staging Jun 8, 2019
@nvaccessAuto nvaccessAuto added this to the 2019.3 milestone Jun 8, 2019

@feerrenrut feerrenrut left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks @josephsl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants