Merge lp:~brian.curtin/ubuntu-sso-client/py3-winreg into lp:ubuntu-sso-client
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | Manuel de la Peña on 2012-06-28 | ||||
| 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) | 2012-06-23 | Approve on 2012-06-28 | |
| Alejandro J. Cura (community) | Approve on 2012-06-28 | ||
|
Review via email:
|
|||
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.
| dobey (dobey) wrote : | # |
| Manuel de la Peña (mandel) wrote : | # |
I agree with dobey, in theory we will be running this on python 3 in the near future.. so making the import fail on python 2 more often than on python 3 makes sense.
- 978. By Brian Curtin on 2012-06-27
-
Try the 3 way and fall back to the 2 way

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).