Merge lp:~brian.curtin/ubuntu-sso-client/py3-winreg into lp:ubuntu-sso-client
Proposed by
Brian Curtin
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Manuel de la Peña | ||||
Approved revision: | 978 | ||||
Merged at revision: | 980 | ||||
Proposed branch: | lp:~brian.curtin/ubuntu-sso-client/py3-winreg | ||||
Merge into: | lp:ubuntu-sso-client | ||||
Diff against target: |
54 lines (+14/-6) 2 files modified
ubuntu_sso/main/tests/test_windows.py (+8/-3) ubuntu_sso/main/windows.py (+6/-3) |
||||
To merge this branch: | bzr merge lp:~brian.curtin/ubuntu-sso-client/py3-winreg | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Manuel de la Peña (community) | Approve | ||
Alejandro J. Cura (community) | Approve | ||
Review via email: mp+111725@code.launchpad.net |
Commit message
Convert _winreg importing to use winreg on both Python 2 and 3
Description of the change
Python 3 changed the _winreg module to winreg. The easiest way to work with that change is to try to import _winreg as winreg, and if that fails, just import winreg since we're on Python 3. Since the names imported from the module are few, move back to importing the module and accessing the names on the module rather than directly importing names from the module. It's easier to maintain that way.
To post a comment you must log in.
I think in these try/except import cases, we should be trying to import the new thing, and only importing the old one if it fails. Doing this also makes it clear by looking at the code, which one is the old one (the fallback).