Skip to content
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: dictionary iteration/list methods made compatible with Python 3 #9671

Merged

Conversation

josephsl
Copy link
Collaborator

@josephsl josephsl commented Jun 5, 2019

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.

…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
Copy link
Collaborator Author

josephsl commented Jun 5, 2019

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
Copy link
Collaborator

LeonarddeR commented Jun 5, 2019 via email

@josephsl
Copy link
Collaborator Author

josephsl commented Jun 5, 2019 via email

@LeonarddeR
Copy link
Collaborator

LeonarddeR commented Jun 5, 2019 via email

@josephsl
Copy link
Collaborator Author

josephsl commented Jun 5, 2019 via email

@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
Copy link
Contributor

@feerrenrut feerrenrut left a comment

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